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

ci: vitest workspaces #998

Merged
merged 8 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
19 changes: 0 additions & 19 deletions vitest.config.ts

This file was deleted.

23 changes: 0 additions & 23 deletions vitest.single-threaded.config.ts

This file was deleted.

48 changes: 48 additions & 0 deletions vitest.workspace.ts
Original file line number Diff line number Diff line change
@@ -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,
},
},
]);