diff --git a/stryker.config.json b/stryker.config.json index 4462ae3..dfb3df5 100644 --- a/stryker.config.json +++ b/stryker.config.json @@ -13,7 +13,9 @@ "@stryker-mutator/typescript-checker" ], "testRunner": "vitest", - "checkers": ["typescript"], + "checkers": [ + "typescript" + ], "tsconfigFile": "tsconfig.json", "coverageAnalysis": "perTest", "thresholds": { @@ -21,8 +23,16 @@ "low": 60, "break": 60 }, - "reporters": ["html", "clear-text", "progress"], + "reporters": [ + "html", + "clear-text", + "progress" + ], "htmlReporter": { "fileName": "reports/mutation/mutation.html" - } + }, + "vitest": { + "configFile": "vitest.stryker.config.ts" + }, + "ignoreStatic": true } diff --git a/vitest.stryker.config.ts b/vitest.stryker.config.ts new file mode 100644 index 0000000..e8c2a82 --- /dev/null +++ b/vitest.stryker.config.ts @@ -0,0 +1,37 @@ +import { defineConfig } from "vitest/config"; + +// Vitest config used ONLY by Stryker (wired via stryker.config.json's +// `vitest.configFile`). It deliberately omits the `globalSetup` that starts a +// Postgres testcontainer. +// +// Why: Stryker runs vitest once per mutant batch across `concurrency` workers +// (default: CPU cores - 1). globalSetup fires on every one of those, so a +// Postgres container was being booted and fully migrated to run unit tests that +// take milliseconds — measured at 8.92s of setup for 29ms of tests, and 18 +// concurrent containers observed on the runner. +// +// Consequence: tests that need a database can't run here, so the DB-backed +// files below are excluded along with tests/ (integration). Mutants covered +// only by those report as NoCoverage rather than Survived, which is honest +// signal about unit-test strength instead of a container tax. +export default defineConfig({ + resolve: { + tsconfigPaths: true, + }, + test: { + globals: true, + environment: "node", + include: ["src/**/*.test.ts"], + exclude: [ + "node_modules/**", + "e2e/**", + // Need a live Postgres via tests/global-setup.ts. + "src/lib/demo-mode.test.ts", + "src/lib/simplefin/queries.test.ts", + "src/lib/plaid/queries.test.ts", + "src/lib/jobs/backfill-balances.test.ts", + "src/lib/jobs/backfill-transfers.test.ts", + ], + testTimeout: 30_000, + }, +});