Skip to content

chore(#106): move api coverage config out of the inline test:run script - #158

Merged
G0maa merged 2 commits into
mainfrom
chore/GH-106-move-api-coverage-config-out-of-test-run
Jul 16, 2026
Merged

chore(#106): move api coverage config out of the inline test:run script#158
G0maa merged 2 commits into
mainfrom
chore/GH-106-move-api-coverage-config-out-of-test-run

Conversation

@G0maa

@G0maa G0maa commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Moved the api coverage config into apps/api/node.config.json — Node's built-in test-runner config file (loaded via --experimental-default-config-file). Coverage thresholds, the five excludes, and test-isolation now live under the testRunner namespace, and enable-source-maps under nodeOptions. This is the mechanism the issue's first option hoped for, so no wrapper script is needed.
  • test:run is now a one-linernode --experimental-default-config-file --env-file=.env.test --test "**/*.test.ts", down from a ~500-char inline flag wall that was hard to read and edit.
  • Behaviour is unchanged — same enforced floors (lines 80 / branches 75 / functions 75), same five excludes, same isolation=none, same source maps. --env-file stays inline because Node reads it at early bootstrap, before config-file namespaces are applied; it was never part of the coverage sprawl.
  • Corrected a stale doc — the root CLAUDE.md documented the api floors as branches 80 / functions 90, but the actually-enforced floors were 75 / 75. Fixed, and both CLAUDE.md files now point at the config file.

Testing

Verified locally without the DB-backed suite (a git worktree has no node_modules, and no marsa Postgres is up here — the full build+test run is CI's integration gate):

  1. Reproduced the config-file mechanism empirically on Node v24.11.1: coverage thresholds are enforced (a 50% functions figure vs a 75% floor exits 1; lowering the floor exits 0), and excludes apply.
  2. Confirmed the exact key spellings by probing the binary — coverage/isolation flags belong under testRunner (test-isolation, not experimental-test-isolation); env-file is rejected in the config file, hence kept inline.
  3. The committed node.config.json parses as valid JSON and loads on Node with no validation errors.
  4. format:check passes on all four changed files (prettier 3.8.3). Changes are JSON + Markdown only, so lint ({src,test}/**/*.ts) is unaffected.

CI runs the full pnpm --filter api test pipeline (clean → build → test:setup → test:run) against Postgres — that is where end-to-end parity is confirmed.

Refs #106

Notes

test:run now relies on two --experimental-* flags: --experimental-default-config-file and the pre-existing --experimental-test-coverage. The config-file feature is the sanctioned way to externalise these flags on Node 24, but it is experimental and its shape could change in a future major.

Glossary

Term Definition
node.config.json Node's built-in JSON configuration file (experimental in v24), applied when the process is started with --experimental-default-config-file (loads it from cwd) or --experimental-config-file=<path>.
testRunner namespace A section of node.config.json for test-runner CLI flags (coverage, isolation) that are not permitted in NODE_OPTIONS. Flags that are permitted in NODE_OPTIONS go under nodeOptions instead.
test-isolation Node test-runner option controlling whether each test file runs in its own child process (process) or all in one (none). Set to none here for shared setup and speed. The config-file key omits the experimental- prefix that the CLI flag carries.
Coverage floor A minimum coverage percentage; the run exits non-zero (failing CI) if measured coverage drops below it.
--env-file Node flag that loads environment variables from a file before running. Processed at early bootstrap — before config-file namespaces — so it cannot be moved into node.config.json and stays inline in the script.

Summary by CodeRabbit

  • Tests

    • Centralized API test execution and coverage settings in a dedicated configuration.
    • Coverage checks now enforce minimum thresholds for lines, branches, and functions.
    • Coverage reports exclude test files, generated migrations, and service mocks.
    • Test runs continue to support source maps and use consistent test isolation settings.
  • Documentation

    • Updated testing documentation to reflect the streamlined test command and centralized coverage configuration.

- 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
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@G0maa, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 38 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 466d742a-7316-41c1-a76c-20cad7670848

📥 Commits

Reviewing files that changed from the base of the PR and between 20814d3 and ac04d1d.

📒 Files selected for processing (3)
  • .claude/CLAUDE.md
  • apps/api/.claude/CLAUDE.md
  • package.json
📝 Walkthrough

Walkthrough

API test coverage, source-map, isolation, threshold, and exclusion settings move from the test script into apps/api/node.config.json. Project and API documentation now describe the config-file-driven test setup.

Changes

API test runner configuration

Layer / File(s) Summary
Centralize API test runner configuration
apps/api/node.config.json, apps/api/package.json, .claude/CLAUDE.md, apps/api/.claude/CLAUDE.md
Node test options and coverage thresholds are defined in node.config.json; test:run loads the default configuration, and documentation reflects the updated setup.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

  • marsa-cloud/marsa#40 — Previously added API test coverage thresholds and exclusions directly to the test:run script.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: moving API coverage config from the inline test:run script into a config file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/GH-106-move-api-coverage-config-out-of-test-run

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/api/node.config.json`:
- Around line 2-17: Align the supported Node.js version across
apps/api/package.json, apps/api/node.config.json, and .claude/CLAUDE.md: raise
the package runtime floor above Node 23.10.0 to support test:run’s experimental
configuration flag, and update the documented version accordingly. If supporting
Node 25.4.0 or newer, rename the node.config.json testRunner key to test;
otherwise pin the runtime to the chosen supported version and keep the existing
configuration key.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e9b1aeb9-1f13-4dbc-acaf-70ec9fe18cb8

📥 Commits

Reviewing files that changed from the base of the PR and between 6fd0137 and 20814d3.

📒 Files selected for processing (4)
  • .claude/CLAUDE.md
  • apps/api/.claude/CLAUDE.md
  • apps/api/node.config.json
  • apps/api/package.json

Comment thread apps/api/node.config.json
CodeRabbit flagged that test:run now depends on
--experimental-default-config-file (Node 23.10.0+), while engines.node
declared >=22. Raise the floor to >=24 to match the pinned runtime
(.nvmrc 24.15.0, used by CI) and clear the flag's minimum. Keep the
testRunner namespace — the test rename is Node 25.4.0+, out of scope.

- package.json: engines.node ">=22" -> ">=24"
- .claude/CLAUDE.md + apps/api/.claude/CLAUDE.md: docs "Node >= 22" -> ">= 24"

Refs #106

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@G0maa
G0maa merged commit 40ab5a2 into main Jul 16, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant