Quick Reference
| Topic | Link |
|---|---|
| Coverage metrics | Statements, branches, functions, lines |
| Instrument your app | babel-plugin-istanbul, nyc, vite-plugin-istanbul |
| Enable coverage | CLI flags and reporter config |
| Coverage fixture | Auto-fixture and manual fixture |
| Sharded runs | Merge coverage across CI shards |
| Data handling | What gets uploaded and stored |
| Troubleshooting | Common issues and fixes |
Coverage Metrics
TestDino tracks four standard coverage metrics:| Metric | What it measures |
|---|---|
| Statements | How many individual code statements ran |
| Branches | How many if/else paths were taken (both the true and false side) |
| Functions | How many functions were called at least once |
| Lines | How many source lines ran |
Prerequisites
@testdino/playwrightinstalled (CLI reference)- TestDino API token (generate one)
- Your application instrumented with Istanbul so
window.__coverage__is available in the browser
Instrument Your Application
Instrumentation adds small tracking counters around every statement, branch, and function in your code. When your app runs, these counters record what was executed. The result is stored in a globalwindow.__coverage__ object that TestDino reads after each test.
Pick the method that matches your build tool:
- babel-plugin-istanbul
- vite-plugin-istanbul
- nyc instrument
Best for React apps using Babel (Create React App, Next.js with Babel, etc.).Install the plugin:Add it to your Babel config so it only runs during test builds:Build with instrumentation enabled:
babel.config.json
Recommended Build Strategy
Only use instrumented builds for test environments. All other environments should use regular builds.| Environment | Build Type | NODE_ENV | Purpose |
|---|---|---|---|
| Development | Regular | development | Local development |
| Testing / QA | Instrumented | test | E2E tests with coverage |
| Staging | Regular | production | Pre-production validation |
| Production | Regular | production | Live users |
Enable Coverage
There are two ways to enable coverage: CLI flags or reporter config. Both produce the same result.CLI Flags
Pass coverage flags directly totdpw test:
| Flag | Description |
|---|---|
--coverage | Enable coverage collection |
--coverage-report | Generate a local Istanbul HTML report |
--coverage-report-dir | Output directory for the local report (default: ./coverage) |
Reporter Config
Add thecoverage option to the @testdino/playwright reporter in your Playwright config:
playwright.config.ts
Coverage Options
| Option | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | Turn on coverage collection |
localReport | boolean | false | Generate a local Istanbul HTML report |
localReportDir | string | ./coverage | Output directory for the local report |
Use the Coverage Fixture
The fixture is the piece that readswindow.__coverage__ from the browser after each test finishes. The reporter then merges all the collected data and sends it to TestDino.
- Auto-fixture (Recommended)
- Manual fixture
Change your import from Coverage collection runs automatically after each test. No other code changes needed.
@playwright/test to @testdino/playwright. Everything else stays the same:tests/example.spec.ts
Run Tests
Review results
After tests complete, the console prints a coverage summary table.If
localReport is enabled, open ./coverage-report/index.html for the full Istanbul HTML report.Open the test run in TestDino and select the Coverage tab to see overall metrics and a per-file breakdown.Sharded Runs
When you split tests across multiple CI shards, each shard collects coverage only for the tests it runs. TestDino merges all shard data into one combined report. Step 1: Set a CI run ID so all shards group into one test run:auth.ts and shard 2 covers lines 30-80, the merged report shows lines 1-80 as covered.
Example CI Workflow
.github/workflows/coverage.yml
Data Handling
TestDino uploads only coverage metrics (percentages and hit counts per file). No source code, raw coverage maps, orwindow.__coverage__ payloads are stored on the server.
| Data | Stored on server | Purpose |
|---|---|---|
| Per-run summary (statements, branches, functions, lines) | Yes | Dashboard summary tiles |
| Per-file metrics (path, percentages, hit counts) | Yes | File-by-file breakdown and trends |
| Source code | No | Never leaves your machine |
| Raw Istanbul coverage maps | No | Processed locally, then discarded |
When
window.__coverage__ is not present in the browser, the reporter skips coverage collection and proceeds normally. Tests run without any performance impact.Troubleshooting
No coverage data collected
No coverage data collected
Open your app in the browser and type
window.__coverage__ in the DevTools console. If it returns undefined, your app is not instrumented.Check that:- Your build command uses
NODE_ENV=testorVITE_COVERAGE=true coverage.enabledis set totruein the reporter config- Your test files import
testfrom@testdino/playwright(not@playwright/test)
Coverage only from one browser
Coverage only from one browser
This is expected when
coverage.projects is set to a single browser (for example, ['chromium']). To collect coverage from all browsers, remove the projects option.Missing files in coverage report
Missing files in coverage report
Only files that run during tests appear in the report. If a file shows 0% or is missing, no test triggered the code path that imports it.To include all source files (even untouched ones), configure your Istanbul tool’s
include/exclude settings to cover the full source directory.Branch coverage is lower than line coverage
Branch coverage is lower than line coverage
This is normal. Branch coverage counts both sides of every
if/else. If your tests only exercise one side (for example, the success path but not the error path), branch coverage drops while line coverage stays higher.Debug coverage collection
Debug coverage collection
Enable debug logging to see what the reporter collects:Check the console for messages prefixed with
[TestDino].