diff --git a/backend/vitest.config.js b/backend/vitest.config.js index c4ee0a9f..8d469ecc 100644 --- a/backend/vitest.config.js +++ b/backend/vitest.config.js @@ -3,10 +3,39 @@ import { defineConfig } from "vitest/config"; export default defineConfig({ test: { environment: "node", - // Run tests in a forked child process that uses Node's native CJS - // module resolution instead of Vite's ESM pipeline. This prevents - // Vite's vite:import-analysis plugin from trying to parse require() - // calls in CJS source files as ESM, which throws SyntaxErrors. + + // Use forked processes for better Node.js compatibility. + // This supports CommonJS modules and avoids ESM import-analysis + // issues when testing backend files that use require(). + pool: "forks", + + // Run tests sequentially within each fork. + fileParallelism: false, + + // Display clear test results. + reporters: ["default"], + + // Restore mocks between tests. + restoreMocks: true, + clearMocks: true, + + // Reset test state between test files. + isolate: true, + + // Enable coverage configuration. + coverage: { + enabled: false, + reporter: ["text", "html"], + exclude: [ + "node_modules/**", + "coverage/**", + "**/*.config.js", + "**/*.config.ts", + "**/test/**", + "**/*.test.js", + "**/*.spec.js", + ], + }, }, });