Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Type issue in vitest workspace #37

Open
Stanzilla opened this issue Mar 28, 2025 · 0 comments
Open

[Bug] Type issue in vitest workspace #37

Stanzilla opened this issue Mar 28, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Stanzilla
Copy link

Describe the bug

I'm using storybookNextJsPlugin in a vitest.workspace.ts file and it errors about a type miss-match.

Steps to reproduce the behavior

vite 6.2.3
vitest 2.1.9
storybook 8.6.11

import { defineWorkspace } from "vitest/config";
import { storybookTest } from "@storybook/experimental-addon-test/vitest-plugin";
import { storybookNextJsPlugin } from "@storybook/experimental-nextjs-vite/vite-plugin";
import { join } from "path";

import { resolveRoot } from "@company/tools-esm/helpers/paths";

const { MR_ID } = process.env;
const IS_CI = process.env.IS_CI || "false";

export default defineWorkspace([
  {
    extends: "./vite.config.mts",
    plugins: [
      storybookTest({
        // This should match your package.json script to run Storybook
        // The --ci flag will skip prompts and not open a browser
        storybookScript: "yarn storybook --ci",
        storybookUrl: (() => {
          if (IS_CI !== "true") return "http://local.company-stage.com:9002";
          return MR_ID
            ? `https://storybook-web-next-${MR_ID}.company-stage.com/`
            : `https://storybook-web-next.company-stage.com/`;
        })(),
      }),
      storybookNextJsPlugin({
        dir: join(resolveRoot(), "projects", "web-next"),
      }),
    ],
    test: {
      name: "storybook",
      // Enable browser mode
      browser: {
        enabled: true,
        name: "chromium",
        // Make sure to install Playwright
        provider: "playwright",
        headless: true,
      },
      // Speed up tests and better match how they run in Storybook itself
      // https://vitest.dev/config/#isolate
      // Consider removing this if you have flaky tests
      isolate: false,
      setupFiles: ["./.storybook/vitest.setup.ts"],
    },
  },
  {
    extends: "./vite.config.mts",
    test: {
      include: ["./**/*.test.ts"],
      name: "unit",
      environment: "node",
    },
  },
]);

Expected behavior

No error

Screenshots and/or logs

Type 'Plugin<any>[]' is not assignable to type 'PluginOption'.
  Type 'Plugin<any>[]' is not assignable to type 'PluginOption[]'.
    Type 'Plugin<any>' is not assignable to type 'PluginOption'.
      Type 'import("/Users/b.s/project/node_modules/vite/dist/node/index").Plugin<any>' is not assignable to type 'import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").Plugin<any>'.
        Types of property 'apply' are incompatible.
          Type '"build" | "serve" | ((this: void, config: import("/Users/b.s/project/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/b.s/project/node_modules/vite/dist/node/index").ConfigEnv) => boolean) | undefined' is not assignable to type '"build" | "serve" | ((this: void, config: import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").ConfigEnv) => boolean) | und...'.
            Type '(this: void, config: UserConfig, env: ConfigEnv) => boolean' is not assignable to type '"build" | "serve" | ((this: void, config: UserConfig, env: ConfigEnv) => boolean) | undefined'.
              Type '(this: void, config: import("/Users/b.s/project/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/b.s/project/node_modules/vite/dist/node/index").ConfigEnv) => boolean' is not assignable to type '(this: void, config: import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").ConfigEnv) => boolean'.
                Types of parameters 'config' and 'config' are incompatible.
                  Type 'import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").UserConfig' is not assignable to type 'import("/Users/b.s/project/node_modules/vite/dist/node/index").UserConfig'.
                    Types of property 'plugins' are incompatible.
                      Type 'import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").PluginOption[] | undefined' is not assignable to type 'import("/Users/b.s/project/node_modules/vite/dist/node/index").PluginOption[] | undefined'.
                        Type 'import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").PluginOption[]' is not assignable to type 'import("/Users/b.s/project/node_modules/vite/dist/node/index").PluginOption[]'.
                          Type 'import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").PluginOption' is not assignable to type 'import("/Users/b.s/project/node_modules/vite/dist/node/index").PluginOption'.
                            Type 'Plugin<any>' is not assignable to type 'PluginOption'.
                              Type 'import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").Plugin<any>' is not assignable to type 'import("/Users/b.s/project/node_modules/vite/dist/node/index").Plugin<any>'.
                                Types of property 'apply' are incompatible.
                                  Type '"build" | "serve" | ((this: void, config: import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").ConfigEnv) => boolean) | und...' is not assignable to type '"build" | "serve" | ((this: void, config: import("/Users/b.s/project/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/b.s/project/node_modules/vite/dist/node/index").ConfigEnv) => boolean) | undefined'.
                                    Type '(this: void, config: UserConfig, env: ConfigEnv) => boolean' is not assignable to type '"build" | "serve" | ((this: void, config: UserConfig, env: ConfigEnv) => boolean) | undefined'.
                                      Type '(this: void, config: import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").ConfigEnv) => boolean' is not assignable to type '(this: void, config: import("/Users/b.s/project/node_modules/vite/dist/node/index").UserConfig, env: import("/Users/b.s/project/node_modules/vite/dist/node/index").ConfigEnv) => boolean'.
                                        Types of parameters 'config' and 'config' are incompatible.
                                          Type 'import("/Users/b.s/project/node_modules/vite/dist/node/index").UserConfig' is not assignable to type 'import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").UserConfig'.
                                            Types of property 'plugins' are incompatible.
                                              Type 'import("/Users/b.s/project/node_modules/vite/dist/node/index").PluginOption[] | undefined' is not assignable to type 'import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").PluginOption[] | undefined'.
                                                Type 'import("/Users/b.s/project/node_modules/vite/dist/node/index").PluginOption[]' is not assignable to type 'import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").PluginOption[]'.
                                                  Type 'import("/Users/b.s/project/node_modules/vite/dist/node/index").PluginOption' is not assignable to type 'import("/Users/b.s/project/node_modules/vitest/node_modules/vite/dist/node/index").PluginOption'.
                                                    Type 'Promise<Plugin<any> | FalsyPlugin | PluginOption[]>' is not assignable to type 'PluginOption'.
                                                      Type 'Promise<Plugin<any> | FalsyPlugin | PluginOption[]>' is not assignable to type 'Promise<false | Plugin<any> | PluginOption[] | null | undefined>'.
                                                        Type 'Plugin<any> | FalsyPlugin | PluginOption[]' is not assignable to type 'false | Plugin<any> | PluginOption[] | null | undefined'.
                                                          Type 'Plugin<any>' is not assignable to type 'false | Plugin<any> | PluginOption[] | null | undefined'.

Environment

  • OS: [e.g. iOS] macOS 15.3
  • Node.js version: [e.g. v12.17.0] 22.14.0
  • NPM version: [e.g. 6.14.4] yarn 1.22
  • Browser (if applicable): [e.g. chrome, safari]
  • Browser version (if applicable): [e.g. 22]
  • Device (if applicable): [e.g. iPhone6]

Additional context

Add any other context about the problem here.

@Stanzilla Stanzilla added the bug Something isn't working label Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant