test: support to run/watch all tests in vscode (@fehmer) (#6868)

This commit is contained in:
Christian Fehmer 2025-08-13 11:14:21 +02:00 committed by GitHub
parent d52af936f6
commit 3447907d09
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 158 additions and 64 deletions

View file

@ -1,72 +1,60 @@
import { defineConfig } from "vitest/config";
import { defineConfig, UserWorkspaceConfig } from "vitest/config";
export const projects: UserWorkspaceConfig[] = [
{
test: {
name: { label: "unit", color: "blue" },
globals: true,
setupFiles: ["__tests__/setup-tests.ts"],
include: ["__tests__/**/*.spec.ts"],
exclude: ["__tests__/__integration__"],
sequence: {
groupOrder: 0,
},
},
},
{
test: {
name: { label: "integration", color: "yellow" },
globals: true,
setupFiles: ["__tests__/__integration__/setup-integration-tests.ts"],
globalSetup: "__tests__/__integration__/global-setup.ts",
include: ["__tests__/__integration__/**/*.spec.ts"],
exclude: ["**/*.isolated.spec.ts"],
sequence: {
concurrent: false,
groupOrder: 1,
},
},
},
{
test: {
name: { label: "integration-isolated", color: "magenta" },
globals: true,
setupFiles: ["__tests__/__integration__/setup-integration-tests.ts"],
globalSetup: "__tests__/__integration__/global-setup.ts",
include: ["__tests__/__integration__/**/*.isolated.spec.ts"],
sequence: {
concurrent: false,
groupOrder: 2,
},
pool: "threads",
poolOptions: {
threads: {
singleThread: true,
},
},
},
},
];
export default defineConfig({
test: {
projects: [
{
extends: true,
test: {
name: { label: "unit", color: "blue" },
setupFiles: ["__tests__/setup-tests.ts"],
include: ["__tests__/**/*.spec.ts"],
exclude: ["__tests__/__integration__"],
sequence: {
groupOrder: 0,
},
},
},
{
extends: true,
test: {
name: { label: "integration", color: "yellow" },
setupFiles: ["__tests__/__integration__/setup-integration-tests.ts"],
globalSetup: "__tests__/__integration__/global-setup.ts",
include: ["__tests__/__integration__/**/*.spec.ts"],
exclude: ["**/*.isolated.spec.ts"],
sequence: {
concurrent: false,
groupOrder: 1,
},
},
},
{
extends: true,
test: {
name: { label: "integration-isolated", color: "magenta" },
setupFiles: ["__tests__/__integration__/setup-integration-tests.ts"],
globalSetup: "__tests__/__integration__/global-setup.ts",
include: ["__tests__/__integration__/**/*.isolated.spec.ts"],
sequence: {
concurrent: false,
groupOrder: 2,
},
pool: "threads",
poolOptions: {
threads: {
singleThread: true,
},
},
},
},
],
projects: projects,
globals: true,
environment: "node",
pool: "forks",
// globalSetup: "__tests__/global-setup.ts",
/*setupFiles: isIntegrationTest
? ["__tests__/__integration__/setup-integration-tests.ts"]
: ["__tests__/setup-tests.ts"],
//pool: "forks", //this should be the default value, however the CI fails without this set.
// run integration tests single threaded bevcause they share the same mongodb
pool: isIntegrationTest ? "threads" : "forks",
poolOptions: {
threads: {
singleThread: true,
},
},
*/
coverage: {
include: ["**/*.ts"],
},

View file

@ -74,7 +74,8 @@
"only-allow": "1.2.1",
"oxlint": "1.11.1",
"prettier": "2.8.8",
"turbo": "2.3.3"
"turbo": "2.3.3",
"vitest": "3.2.4"
},
"lint-staged": {
"*.{json,scss,css,html}": [

90
pnpm-lock.yaml generated
View file

@ -44,6 +44,9 @@ importers:
turbo:
specifier: 2.3.3
version: 2.3.3
vitest:
specifier: 3.2.4
version: 3.2.4(@types/node@20.5.1)(happy-dom@15.10.2)(sass@1.70.0)(terser@5.43.1)(tsx@4.16.2)(yaml@2.5.0)
backend:
dependencies:
@ -13252,6 +13255,14 @@ snapshots:
optionalDependencies:
vite: 6.3.4(@types/node@20.14.11)(sass@1.70.0)(terser@5.43.1)(tsx@4.16.2)(yaml@2.5.0)
'@vitest/mocker@3.2.4(vite@6.3.4(@types/node@20.5.1)(sass@1.70.0)(terser@5.43.1)(tsx@4.16.2)(yaml@2.5.0))':
dependencies:
'@vitest/spy': 3.2.4
estree-walker: 3.0.3
magic-string: 0.30.17
optionalDependencies:
vite: 6.3.4(@types/node@20.5.1)(sass@1.70.0)(terser@5.43.1)(tsx@4.16.2)(yaml@2.5.0)
'@vitest/pretty-format@3.2.4':
dependencies:
tinyrainbow: 2.0.0
@ -21541,6 +21552,27 @@ snapshots:
- tsx
- yaml
vite-node@3.2.4(@types/node@20.5.1)(sass@1.70.0)(terser@5.43.1)(tsx@4.16.2)(yaml@2.5.0):
dependencies:
cac: 6.7.14
debug: 4.4.1
es-module-lexer: 1.7.0
pathe: 2.0.3
vite: 6.3.4(@types/node@20.5.1)(sass@1.70.0)(terser@5.43.1)(tsx@4.16.2)(yaml@2.5.0)
transitivePeerDependencies:
- '@types/node'
- jiti
- less
- lightningcss
- sass
- sass-embedded
- stylus
- sugarss
- supports-color
- terser
- tsx
- yaml
vite-plugin-checker@0.7.2(eslint@8.57.1)(optionator@0.9.4)(typescript@5.5.4)(vite@6.3.4(@types/node@20.14.11)(sass@1.70.0)(terser@5.43.1)(tsx@4.16.2)(yaml@2.5.0)):
dependencies:
'@babel/code-frame': 7.24.7
@ -21623,6 +21655,22 @@ snapshots:
tsx: 4.16.2
yaml: 2.5.0
vite@6.3.4(@types/node@20.5.1)(sass@1.70.0)(terser@5.43.1)(tsx@4.16.2)(yaml@2.5.0):
dependencies:
esbuild: 0.25.0
fdir: 6.4.4(picomatch@4.0.2)
picomatch: 4.0.2
postcss: 8.5.3
rollup: 4.40.0
tinyglobby: 0.2.13
optionalDependencies:
'@types/node': 20.5.1
fsevents: 2.3.3
sass: 1.70.0
terser: 5.43.1
tsx: 4.16.2
yaml: 2.5.0
vitest@3.2.4(@types/node@20.14.11)(happy-dom@15.10.2)(sass@1.70.0)(terser@5.43.1)(tsx@4.16.2)(yaml@2.5.0):
dependencies:
'@types/chai': 5.2.2
@ -21665,6 +21713,48 @@ snapshots:
- tsx
- yaml
vitest@3.2.4(@types/node@20.5.1)(happy-dom@15.10.2)(sass@1.70.0)(terser@5.43.1)(tsx@4.16.2)(yaml@2.5.0):
dependencies:
'@types/chai': 5.2.2
'@vitest/expect': 3.2.4
'@vitest/mocker': 3.2.4(vite@6.3.4(@types/node@20.5.1)(sass@1.70.0)(terser@5.43.1)(tsx@4.16.2)(yaml@2.5.0))
'@vitest/pretty-format': 3.2.4
'@vitest/runner': 3.2.4
'@vitest/snapshot': 3.2.4
'@vitest/spy': 3.2.4
'@vitest/utils': 3.2.4
chai: 5.2.1
debug: 4.4.1
expect-type: 1.2.2
magic-string: 0.30.17
pathe: 2.0.3
picomatch: 4.0.3
std-env: 3.9.0
tinybench: 2.9.0
tinyexec: 0.3.2
tinyglobby: 0.2.14
tinypool: 1.1.1
tinyrainbow: 2.0.0
vite: 6.3.4(@types/node@20.5.1)(sass@1.70.0)(terser@5.43.1)(tsx@4.16.2)(yaml@2.5.0)
vite-node: 3.2.4(@types/node@20.5.1)(sass@1.70.0)(terser@5.43.1)(tsx@4.16.2)(yaml@2.5.0)
why-is-node-running: 2.3.0
optionalDependencies:
'@types/node': 20.5.1
happy-dom: 15.10.2
transitivePeerDependencies:
- jiti
- less
- lightningcss
- msw
- sass
- sass-embedded
- stylus
- sugarss
- supports-color
- terser
- tsx
- yaml
vlq@0.2.3: {}
vscode-json-languageservice@4.2.1:

15
vitest.config.ts Normal file
View file

@ -0,0 +1,15 @@
import { defineConfig, UserWorkspaceConfig } from "vitest/config";
import { projects as backendProjects } from "./backend/vitest.config";
export default defineConfig({
test: {
projects: [
...backendProjects.map(
(it) =>
({ test: { ...it.test, root: "backend" } } as UserWorkspaceConfig)
),
"frontend/vitest.config.ts",
"packages/**/vitest.config.ts",
],
},
});