diff --git a/backend/vitest.config.ts b/backend/vitest.config.ts index 8be1f1811..8526bdb58 100644 --- a/backend/vitest.config.ts +++ b/backend/vitest.config.ts @@ -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"], }, diff --git a/package.json b/package.json index bdf2143c7..87ce1ee7e 100644 --- a/package.json +++ b/package.json @@ -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}": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e92fab65c..ba6d4a0a8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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: diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 000000000..e84681643 --- /dev/null +++ b/vitest.config.ts @@ -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", + ], + }, +});