# Playwright code coverage of your server: Express, measured > Playwright code coverage for the server: why c8 around the webServer writes nothing, the gracefulShutdown and SIGTERM fix, and server coverage per test. Web page: https://supercov.com/blog/playwright-server-coverage · Published 2026-12-05 All Supercov pages for agents: https://supercov.com/llms.txt · Full text: https://supercov.com/llms-full.txt 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()`. ![A diagram: playwright test starts the webServer, node src/server.js. When it is stopped by a signal, Node writes no coverage. With process.exit() on SIGTERM, c8 reports the server. c8 needs gracefulShutdown SIGTERM in the config and a SIGTERM handler; Supercov needs neither and splits the server's coverage by test.](https://supercov.com/assets/playwright-server-coverage-flow-1360.aa93d76cca.webp) *How the server's coverage gets written.* 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](#supercov-no-changes-per-test). ## 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. ![A grid of four setups against server lines, per test and conditions. c8 around webServer: no report. Plus gracefulShutdown SIGTERM: 0 of 0 lines. Plus process.exit on SIGTERM: server lines, 21 of 25. supercov -- npx playwright test: server lines, per test and conditions, 14 of 17 lines.](https://supercov.com/assets/playwright-server-coverage-grid-1360.cfe86c87f4.webp) *What each setup reported for the Express server.* ## c8 around the webServer: three settings, all needed Put c8 in front of the server command in `playwright.config.js`: ```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 `gracefulShutdown` and 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 --import` so the app stayed unchanged: ```js // exit-on-sigterm.mjs process.on('SIGTERM', () => process.exit(0)); ``` ```sh 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](https://supercov.com/blog/merge-coverage-reports.md). ## Supercov: no changes, per test ```sh npx supercov -- npx playwright test npx supercov runs latest file src/server.js ``` ```text Gaps 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](https://supercov.com/docs/supported-suites.md). For the same question in unit tests, see [which test covers this line](https://supercov.com/blog/which-test-covers-this-line.md).