Playwright code coverage of your server: Express, measured
Two Playwright tests against an Express app, and the three settings c8 needed before it reported a single server line.

Playwright’s coverage API measures JavaScript in the browser, in Chromium. Your
server’s code, the Express routes the tests call, needs a coverage tool around
the server process, and that tool only writes its data when the server exits
normally. By default Playwright stops the webServer with a signal, so c8
reported nothing in our runs until we set gracefulShutdown and added a
SIGTERM handler that calls process.exit().

Supercov, which we make, measures the server under npx supercov -- npx playwright test with no change to the server or the config, and splits its
coverage by Playwright test. See below.
At a glance
| Setup | Server coverage | Per test |
|---|---|---|
page.coverage | None: browser JavaScript only, Chromium only | Yes, if you start and stop it per test |
c8 around the webServer command | No report | No |
+ gracefulShutdown: { signal: 'SIGTERM' } | A report with 0 of 0 lines | No |
+ process.on('SIGTERM', () => process.exit(0)) | Yes | No |
npx supercov -- npx playwright test | Yes, with branches and MC/DC | Yes |
We measured with Playwright 1.65.1, Express 5.2.1, c8 11.0.0 and Node 24: an
Express app with a /api/price route and a discount function, a static page
that calls it, and two Playwright tests.

c8 around the webServer: three settings, all needed
Put c8 in front of the server command in playwright.config.js:
webServer: {
command: 'c8 --reporter=text --include="src/**" node src/server.js',
url: 'http://localhost:3100',
gracefulShutdown: { signal: 'SIGTERM', timeout: 2000 },
},
Node writes V8 coverage when the process exits, not when a signal kills it.
- Without
gracefulShutdown, Playwright kills the server and c8 with it. No report was written. - With
gracefulShutdownand SIGTERM, c8 reported, but 0 of 0 lines. The server still died from the signal, so its coverage file never appeared. - With a SIGTERM handler that exits, c8 reported the server: 21 of 25
lines, 6 of 8 branches. We loaded the handler with
node --importso the app stayed unchanged:
// exit-on-sigterm.mjs
process.on('SIGTERM', () => process.exit(0));c8 --reporter=text --include="src/**" node --import ./exit-on-sigterm.mjs src/server.js
The report covers the whole Playwright run. It can’t say which test ran a route, and to combine it with unit-test coverage you merge the two reports yourself. See merge coverage reports.
Supercov: no changes, per test
npx supercov -- npx playwright test
npx supercov runs latest file src/server.jsGaps
NOT COVERED = line never executed; PARTIAL = line executed but some behavior remains untested
LINE STATUS SOURCE
9 PARTIAL !Number.isInteger(cents) || cents < 0
Unobserved: decision never true
Unobserved: `!Number.isInteger(cents)` was never true; needs `!Number.isInteger(cents)` true, decision true
Unobserved: `cents < 0` was never true; needs `!Number.isInteger(cents)` false, `cents < 0` true, decision true
Inspect: npx supercov runs 'run_c05697f6caa2565a' line 'src/server.js:9'
10 NOT COVERED res.status(400).json({ error: 'cents must be a whole number' });
11 NOT COVERED return;
The run reported the server and discount.js at 14 of 17 lines, 5 of 8
branches and 1 of 5 MC/DC conditions. Both tools found the same untested code:
the 400 response and the return cents; no test reached. They count lines
differently, so the totals differ. supercov runs latest line src/discount.js:6 named the one test that ran it, TENOFF takes ten off orders of ten or more.
The same works for servers in Python, Ruby, Go, Java and Kotlin, and Rust Workers, under browser tests: see runner support. For the same question in unit tests, see which test covers this line.
More coverage guides
- Ruby && and || coverage: what SimpleCov's branch coverage misses
- JaCoCo coverage per test: which test covers this line in Java
- Code coverage for AI coding agents: what the agent reads
- Which test covers this line? Vitest, Jest and pytest
- Jest coverageThreshold: global, per-folder and per-file
- JaCoCo aggregate report for multi-module Maven and Gradle builds
- pytest ignore directory: --ignore, norecursedirs and collect_ignore
- Merge coverage reports from shards: Vitest, Jest and coverage.py
- Statement vs branch coverage, with decision, line and path coverage
- JaCoCo report not generated: the causes in Maven and Gradle
- Kover exclude: classes, packages and generated code
- sonar.coverage.exclusions: why SonarQube ignores your JaCoCo excludes
- istanbul ignore next vs c8 ignore next: every hint, measured
- Go test coverage exclude: files, packages and mocks
- Jest coverage exclude: files, folders and lines
- pytest coverage exclude: omit files, folders and lines
- Vitest coverage exclude: files, folders and lines
- JaCoCo exclude in Maven and Gradle: packages, classes and generated code