diff --git a/.changeset/tough-peas-retire.md b/.changeset/tough-peas-retire.md new file mode 100644 index 00000000000..a845151cc84 --- /dev/null +++ b/.changeset/tough-peas-retire.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/package.json b/package.json index d40dcf45e44..f6f59e14468 100644 --- a/package.json +++ b/package.json @@ -17,15 +17,15 @@ "pretest": "turbo run pretest", "depcheck": "knip --dependencies --tags=-knipignore", "knip:fix": "knip --fix", - "test": "vitest --run --coverage --config vite.node.config.mts $(scripts/tests-find.sh --node)", - "test:filter": "vitest --run --coverage --config vite.node.config.mts", + "test": "vitest --run --coverage --config vitest.node.config.mts $(scripts/tests-find.sh --node)", + "test:filter": "vitest --run --coverage --config vitest.node.config.mts", "test:coverage-merge": "tsx ./scripts/tests-coverage-merge.ts", "test:coverage-diff": "tsx ./scripts/tests-coverage-diff.ts", - "test:watch": "vitest --watch --config vite.node.config.mts $(scripts/tests-find.sh --node)", + "test:watch": "vitest --watch --config vitest.node.config.mts $(scripts/tests-find.sh --node)", "test:validate": "./scripts/tests-validate.sh", - "test:browser": "vitest --run --coverage --config vite.browser.config.mts $(scripts/tests-find.sh --browser)", - "test:browser:filter": "vitest --run --coverage --config vite.browser.config.mts", - "test:e2e": "vitest --run --config vite.node.config.mts $(scripts/tests-find.sh --e2e)", + "test:browser": "vitest --run --coverage --config vitest.browser.config.mts $(scripts/tests-find.sh --browser)", + "test:browser:filter": "vitest --run --coverage --config vitest.browser.config.mts", + "test:e2e": "vitest --run --config vitest.node.config.mts $(scripts/tests-find.sh --e2e)", "lint": "run-s lint:check prettier:check", "lint:check": "eslint . --ext .ts --max-warnings 0", "lint:fix": "pnpm lint:check --fix", diff --git a/vite.node.config.mts b/vite.node.config.mts deleted file mode 100644 index 57e002b56df..00000000000 --- a/vite.node.config.mts +++ /dev/null @@ -1,14 +0,0 @@ -import type { UserConfig } from "vitest/config"; -import { mergeConfig } from "vitest/config"; - -import baseConfig from "./vite.base.config.mts"; - -const config: UserConfig = { - test: { - coverage: { - reportsDirectory: "coverage/environments/node", - }, - }, -}; - -export default mergeConfig(baseConfig, config); diff --git a/vite.browser.config.mts b/vitest.browser.config.mts similarity index 81% rename from vite.browser.config.mts rename to vitest.browser.config.mts index fd260dd6aa1..8c7b3b0132f 100644 --- a/vite.browser.config.mts +++ b/vitest.browser.config.mts @@ -1,8 +1,8 @@ import { nodePolyfills } from "vite-plugin-node-polyfills"; -import { mergeConfig } from "vitest/config"; import type { UserConfig } from "vitest/config"; +import { mergeConfig, defineProject } from "vitest/config"; -import baseConfig from "./vite.base.config.mts"; +import sharedConfig from "./vitest.shared.config.mts"; const config: UserConfig = { plugins: [ @@ -42,4 +42,4 @@ const config: UserConfig = { }, }; -export default mergeConfig(baseConfig, config); +export default mergeConfig(sharedConfig, defineProject(config)); diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 00000000000..224c9b5a35d --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,24 @@ +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { + coverage: { + enabled: true, + provider: 'istanbul', + reporter: ['json', 'text', 'html'], + include: ['packages', 'internal', 'apps'], + exclude: [ + '**/*.js', + '**/node_modules/**', + '**/dist/**', + '**/test/**', + '**/*.test.ts', + '**/*.d.ts', + '**/bin.ts', + 'packages/fuel-gauge/**', + 'apps/demo-*', + 'apps/docs', + ], + }, + }, +}); diff --git a/vite.env.ts b/vitest.env.ts similarity index 100% rename from vite.env.ts rename to vitest.env.ts diff --git a/vitest.node.config.mts b/vitest.node.config.mts new file mode 100644 index 00000000000..d3b8430251a --- /dev/null +++ b/vitest.node.config.mts @@ -0,0 +1,14 @@ +import type { UserConfig } from "vitest/config"; +import { mergeConfig, defineProject } from "vitest/config"; + +import sharedConfig from "./vitest.shared.config.mts"; + +const config: UserConfig = { + test: { + coverage: { + reportsDirectory: "coverage/environments/node", + }, + }, +}; + +export default mergeConfig(sharedConfig, defineProject(config)); diff --git a/vite.base.config.mts b/vitest.shared.config.mts similarity index 96% rename from vite.base.config.mts rename to vitest.shared.config.mts index ab159041524..08ba4406074 100644 --- a/vite.base.config.mts +++ b/vitest.shared.config.mts @@ -11,16 +11,6 @@ export default defineConfig({ }), ], test: { - exclude: [ - "**/node_modules/**", - "**/dist/**", - "/apps/demo-nextjs", - "/apps/demo-react-cra", - "/apps/demo-react-vite", - ], - globals: true, - setupFiles: ["./vite.env.ts"], - env: loadEnv(mode, process.cwd(), ""), coverage: { enabled: true, provider: "istanbul", @@ -39,6 +29,16 @@ export default defineConfig({ "apps/docs", ], }, + exclude: [ + "**/node_modules/**", + "**/dist/**", + "/apps/demo-nextjs", + "/apps/demo-react-cra", + "/apps/demo-react-vite", + ], + globals: true, + setupFiles: ["./vitest.env.ts"], + env: loadEnv(mode, process.cwd(), ""), poolOptions: { threads: { minThreads: 1, diff --git a/vitest.workspace.ts b/vitest.workspace.ts new file mode 100644 index 00000000000..d5607cb861f --- /dev/null +++ b/vitest.workspace.ts @@ -0,0 +1,3 @@ +import { defineWorkspace } from 'vitest/config'; + +export default defineWorkspace(['./vitest.node.config.mts', './vitest.browser.config.mts']);