Skip to content

Node.js

When the built-in Node.js runner ships, it will:

  • Accept lang: nodejs in nolapse.yaml.
  • Invoke jest --coverage --coverageReporters=json-summary (or c8/v8 for non-Jest projects) automatically.
  • Parse coverage-summary.json to extract the total statement coverage percentage.
  • Respect the same warn_threshold / fail_threshold / strict_mode settings as all other runners.

The expected nolapse.yaml when it is available:

lang: nodejs
warn_threshold: -1.0
fail_threshold: -5.0
strict_mode: false

Until the built-in runner ships you can drive Jest coverage yourself and feed the result to nolapse via a custom runner script.

Add a script to package.json:

{
"scripts": {
"test:coverage": "jest --coverage --coverageReporters=json-summary --coverageDirectory=coverage"
}
}

Create nolapse-runner.sh at the repo root:

#!/usr/bin/env bash
set -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:

Terminal window
chmod +x nolapse-runner.sh
lang: custom
warn_threshold: -1.0
fail_threshold: -5.0

Point nolapse at the script:

Terminal window
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.

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.