Skip to content

Tutorial: Node.js Express API


When Node.js support lands, this tutorial will walk through:

  1. Creating a minimal Express HTTP API with two routes (GET /health and GET /greet)
  2. Writing Jest tests with --coverage to generate a coverage/coverage-summary.json report
  3. Running nolapse init --repo . --lang nodejs to create the baseline
  4. Simulating a coverage regression by removing a test
  5. Running nolapse run --repo . --lang nodejs and seeing it exit 1
  6. Adding a GitHub Actions workflow that gates PRs on coverage

hello-express/
├── src/
│ ├── handler.js
│ └── handler.test.js
├── package.json
├── jest.config.js
├── .audit/
│ └── coverage/
│ └── baseline.md
└── nolapse.yaml

Terminal window
nolapse init --repo . --lang nodejs
Terminal window
nolapse run --repo . --lang nodejs
name: Coverage check
on:
pull_request:
jobs:
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: npm ci
- name: Run nolapse
uses: nolapse/nolapse-action@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
lang: nodejs
warn-threshold: "0.5"
fail-threshold: "1.0"

nolapse will read Jest’s coverage/coverage-summary.json format. To generate it, Jest must be configured with:

{
"coverageReporters": ["json-summary"]
}

Or in jest.config.js:

module.exports = {
coverageReporters: ["json-summary", "text"],
};

Watch the nolapse changelog for the Node.js runner release. Once available, this tutorial will be updated with full working commands and example output.