Node.js
What is planned
Section titled “What is planned”When the built-in Node.js runner ships, it will:
- Accept
lang: nodejsinnolapse.yaml. - Invoke
jest --coverage --coverageReporters=json-summary(orc8/v8for non-Jest projects) automatically. - Parse
coverage-summary.jsonto extract the total statement coverage percentage. - Respect the same
warn_threshold/fail_threshold/strict_modesettings as all other runners.
The expected nolapse.yaml when it is available:
lang: nodejswarn_threshold: -1.0fail_threshold: -5.0strict_mode: falseWorkaround: custom runner
Section titled “Workaround: custom runner”Until the built-in runner ships you can drive Jest coverage yourself and feed the result to nolapse via a custom runner script.
1. Generate a coverage summary
Section titled “1. Generate a coverage summary”Add a script to package.json:
{ "scripts": { "test:coverage": "jest --coverage --coverageReporters=json-summary --coverageDirectory=coverage" }}2. Write a custom runner script
Section titled “2. Write a custom runner script”Create nolapse-runner.sh at the repo root:
#!/usr/bin/env bashset -euo pipefail
REPO_PATH="${1:-.}"cd "$REPO_PATH"
npm test -- --coverage --coverageReporters=json-summary --coverageDirectory=coverage 2>/dev/null
PCT=$(node -e " const s = require('./coverage/coverage-summary.json'); console.log(s.total.statements.pct);")
echo "nolapse-coverage: ${PCT}"Make it executable:
chmod +x nolapse-runner.sh3. Configure nolapse
Section titled “3. Configure nolapse”lang: customwarn_threshold: -1.0fail_threshold: -5.0Point nolapse at the script:
NOLAPSE_RUNNER_PATH=./nolapse-runner.sh nolapse run --repo .See Custom Runner for full details on the runner contract and the output format nolapse expects.
Track the roadmap
Section titled “Track the roadmap”Watch the nolapse changelog and the Node.js runner issue for updates. When the built-in runner lands, you can remove the custom script and switch to lang: nodejs.