Skip to content

Commit 20814d3

Browse files
committed
chore: move api coverage config out of inline test:run
- Move Node's test-runner coverage config (thresholds + excludes + isolation) into apps/api/node.config.json under the testRunner namespace, loaded via --experimental-default-config-file, so test:run is a legible one-liner - Preserve the enforced floors (lines 80 / branches 75 / functions 75), all five coverage excludes, source maps, and isolation=none unchanged - --env-file stays inline (Node reads it at early bootstrap, before config-file namespaces are applied) - Correct stale api coverage floors in root CLAUDE.md (documented 80/90; the actually-enforced floors were 75/75) and point both CLAUDE.md files at the new config file Refs #106
1 parent 6fd0137 commit 20814d3

4 files changed

Lines changed: 23 additions & 3 deletions

File tree

.claude/CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@ Additional git-workflow rules live in `.claude/rules/git-workflow.md`, which Cla
9494
Both test suites enforce a **minimum coverage threshold** — the test step fails (and so does CI) when coverage drops below the floor. The gates ride the existing test steps; there is no separate coverage job.
9595

9696
- **web** (`vitest.config.ts``test.coverage`): v8 provider, scoped to hand-written `app/**` source (generated `app/api/*` and config files excluded). Floors **temporarily lowered** to lines/statements 28%, branches 30%, functions 12% after the vitest v4 upgrade changed instrumentation (it now counts Nuxt-bootstrap-loaded files + untested starter scaffolding that v3 did not) — see [#66](https://github.com/marsa-cloud/marsa/issues/66) to add tests and ratchet them back toward ~88/90/60.
97-
- **api** (`test:run` script): Node's built-in `--experimental-test-coverage` with `--test-coverage-lines=80 --test-coverage-branches=80 --test-coverage-functions=90`; test files and `src/test/**` are excluded. Source-mapped back to `.ts` via `--enable-source-maps`.
97+
- **api** (`apps/api/node.config.json`, loaded by `test:run` via `--experimental-default-config-file`): Node's built-in `--experimental-test-coverage` with floors lines 80 / branches 75 / functions 75 under the `testRunner` namespace; test files, `src/test/**`, generated migrations, and the service mocks are excluded. Source-mapped back to `.ts` via `enable-source-maps`. The coverage config lives in the config file (not an inline flag list) so it stays readable — see [#106](https://github.com/marsa-cloud/marsa/issues/106).
9898

9999
These are **ratchet floors**, set a few points below the coverage measured when the gate was introduced (web ~90% lines, api ~85% lines — see issue #39). Raise them as coverage improves; never lower them to make a red build pass — add tests instead.

apps/api/.claude/CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ pnpm lint:fix
162162

163163
pnpm test # clean → build → test:setup → test:run
164164
pnpm test:setup # global-setup against compiled output
165-
pnpm test:run # node --test with source maps
165+
pnpm test:run # node --test; coverage config in node.config.json
166166
```
167167

168168
`pnpm test` runs the full pipeline. There is no ts-node / watch test mode — change code, rebuild, rerun.

apps/api/node.config.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://nodejs.org/dist/v24.15.0/docs/node-config-schema.json",
3+
"nodeOptions": {
4+
"enable-source-maps": true
5+
},
6+
"testRunner": {
7+
"test-isolation": "none",
8+
"experimental-test-coverage": true,
9+
"test-coverage-lines": 80,
10+
"test-coverage-branches": 75,
11+
"test-coverage-functions": 75,
12+
"test-coverage-exclude": [
13+
"src/test/**",
14+
"**/*.test.ts",
15+
"src/sql/migrations/**",
16+
"src/modules/github-client/mock-github-client.ts",
17+
"src/modules/kubernetes/mock-deploy-backend.ts"
18+
]
19+
}
20+
}

apps/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"migration:up": "node --env-file=.env node_modules/@mikro-orm/cli/cli.js migration:up --config ./dist/src/sql/mikro-orm.config.js",
2727
"migration:down": "node --env-file=.env node_modules/@mikro-orm/cli/cli.js migration:down --config ./dist/src/sql/mikro-orm.config.js",
2828
"test:setup": "node --env-file=.env.test dist/src/test/setup/global-setup.js",
29-
"test:run": "node --enable-source-maps --experimental-test-isolation=none --env-file=.env.test --experimental-test-coverage --test-coverage-lines=80 --test-coverage-branches=75 --test-coverage-functions=75 --test-coverage-exclude=\"src/test/**\" --test-coverage-exclude=\"**/*.test.ts\" --test-coverage-exclude=\"src/sql/migrations/**\" --test-coverage-exclude=\"src/modules/github-client/mock-github-client.ts\" --test-coverage-exclude=\"src/modules/kubernetes/mock-deploy-backend.ts\" --test \"**/*.test.ts\"",
29+
"test:run": "node --experimental-default-config-file --env-file=.env.test --test \"**/*.test.ts\"",
3030
"test": "pnpm clean && pnpm build && pnpm test:setup && pnpm test:run"
3131
},
3232
"dependencies": {

0 commit comments

Comments
 (0)