diff --git a/package.json b/package.json index c610aa335..4b5e27e26 100644 --- a/package.json +++ b/package.json @@ -119,9 +119,7 @@ "prettier": "prettier --check .", "schemas:check": "./bin/json-schema-store.js", "schemas:write": "./bin/json-schema-store.js --update", - "test": "npm run test:multi && npm run test:single", - "test:multi": "vitest run --coverage", - "test:single": "vitest run --coverage --config vitest.single-threaded.config.ts" + "test": "vitest run --coverage" }, "commitlint": { "extends": [ diff --git a/vitest.config.ts b/vitest.config.ts deleted file mode 100644 index 10d82e5fe..000000000 --- a/vitest.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'vitest/config'; - -export default defineConfig({ - test: { - coverage: { - reporter: 'text', - thresholds: { - branches: 80, - functions: 80, - lines: 90, - statements: 90, - }, - }, - exclude: ['**/dist/**', '**/node_modules/**', '**/__fixtures__/**', '**/helpers/**', '**/single-threaded/**'], - globalSetup: ['./__tests__/setup.js'], - setupFiles: ['./__tests__/helpers/vitest.matchers.ts'], - }, -}); diff --git a/vitest.single-threaded.config.ts b/vitest.single-threaded.config.ts deleted file mode 100644 index c0a07923a..000000000 --- a/vitest.single-threaded.config.ts +++ /dev/null @@ -1,23 +0,0 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import { defineConfig } from 'vitest/config'; - -export default defineConfig({ - test: { - coverage: { - reporter: 'text', - }, - exclude: ['**/dist/**', '**/node_modules/**', '**/__fixtures__/**', '**/helpers/**', '**/__snapshots__/**'], - globalSetup: ['./__tests__/setup.js'], - include: ['**/single-threaded/**'], - setupFiles: ['./__tests__/helpers/vitest.matchers.ts'], - - /** - * We can't run tests with `threads` on because we use `process.chdir()` in some tests and - * that isn't available in worker threads, and it's way too much work to mock out an entire - * filesystem and `fs` calls for the tests that use it. - * - * @see {@link https://github.com/vitest-dev/vitest/issues/566} - */ - pool: 'forks', - }, -}); diff --git a/vitest.workspace.ts b/vitest.workspace.ts new file mode 100644 index 000000000..81c06c7c8 --- /dev/null +++ b/vitest.workspace.ts @@ -0,0 +1,48 @@ +// eslint-disable-next-line import/no-extraneous-dependencies +import { defineWorkspace } from 'vitest/config'; + +const sharedExclude = [ + '**/dist/**', + '**/node_modules/**', + '**/__fixtures__/**', + '**/helpers/**', + '**/__snapshots__/**', +]; + +const sharedOpts = { + globalSetup: ['./__tests__/setup.js'], + setupFiles: ['./__tests__/helpers/vitest.matchers.ts'], +}; + +export default defineWorkspace([ + { + /** + * Our default test suite + */ + test: { + exclude: [...sharedExclude, '**/single-threaded/**'], + name: 'default', + ...sharedOpts, + }, + }, + { + /** + * Our single-threaded test suite. + * Only tests that use `process.chdir()` should be run using this config. + */ + test: { + exclude: sharedExclude, + include: ['**/single-threaded/**'], + name: 'single-threaded', + /** + * We can't run tests with `threads` on because we use `process.chdir()` in some tests and + * that isn't available in worker threads, and it's way too much work to mock out an entire + * filesystem and `fs` calls for the tests that use it. + * + * @see {@link https://github.com/vitest-dev/vitest/issues/566} + */ + pool: 'forks', + ...sharedOpts, + }, + }, +]);