Skip to content

CLI ​

This page is the reference for the playwright-ui-coverage command: rebuilding the report, checking and updating a baseline, comparing runs, and printing a summary. It works on files the reporter already wrote, so none of the commands run tests.

bash
npx playwright-ui-coverage <command> [options]
npx playwright-ui-coverage --help
CommandWhat it does
reportRebuild the report (index.html, coverage.json) from stored data, applying the rules in the config file.
baseline checkExit 1 if coverage.json has untested elements the baseline doesn't list; writes <file>.next.json.
baseline updateWrite the baseline file from coverage.json.
compare <base> <head>Compare two coverage.json files: coverage delta, new untested elements, resolved gaps, added/removed views.
summary [coverage.json]Markdown summary of one run (what githubSummary writes).

Exit codes ​

CodeMeaning
0OK. compare and summary always exit with 0 unless there's an error.
1A threshold isn't met, or the baseline check found new untested elements (report, baseline check).
2Usage or input error: bad flags, unreadable data, an invalid config, an unknown profile.

report ​

Rebuild the report from the data folder the reporter keeps (ui-coverage-report/data/), e.g. after changing a filter, without running the tests:

bash
npx playwright-ui-coverage report
npx playwright-ui-coverage report --profile pr-critical
npx playwright-ui-coverage report --data ci-artifacts/ui-coverage-report/data --config other.config.mjs --out ui-coverage-report
FlagDefault
--config <file>UI_COVERAGE_CONFIG, else ui-coverage.config.* in the working directory, else default optionsThe config file: .json, .js/.cjs (module.exports = {…}), .mjs (export default {…}), .ts/.mts/.cts (loaded with Playwright's TypeScript support). Relative paths in it resolve from its folder. recording is ignored here (nothing is recorded).
--profile <name>UI_COVERAGE_PROFILE, else the profile the reporter used, else automaticThe profile to apply; '' for none.
--data <dir>data/ in the config's outputFolder (else ui-coverage-report/data)The data folder.
--out <dir>the folder that contains --dataWhere to write the report. Only index.html, coverage.json and screens/ are replaced; nothing else is deleted.

threshold and baseline are checked like in the reporter: the CLI exits with code 1 if a threshold isn't met or there are new untested elements, and 2 on errors. With githubSummary: true it appends the step summary too.

What a rebuild can and can't change is described in How it works.

baseline ​

Check or update a baseline from an existing coverage.json:

bash
npx playwright-ui-coverage baseline check  [--report ui-coverage-report/coverage.json] [--file ui-coverage-baseline.json] [--allow-new-views] [--config <file>]
npx playwright-ui-coverage baseline update [--report ui-coverage-report/coverage.json] [--file ui-coverage-baseline.json] [--config <file>]
FlagDefault
--report <file>coverage.json in the config's outputFolder, else ui-coverage-report/coverage.jsonThe run to check.
--file <file>the config's baseline.file, else ui-coverage-baseline.jsonThe baseline file.
--allow-new-viewsoffcheck: untested elements of views not in the baseline don't fail.
--config <file>as for reportReads outputFolder and baseline from the config.
--profile <name>UI_COVERAGE_PROFILEThe profile to apply.

check exits with 1 on new gaps (and writes <file>.next.json), 2 on errors.

compare ​

Compare two coverage.json files, e.g. the latest run on main and a pull request's run. See Comparing runs and PR comments for what it reports.

bash
npx playwright-ui-coverage compare base/coverage.json ui-coverage-report/coverage.json [--format markdown|json] [--out file] [--report-url <url>] [--title <text>]
FlagDefault
--format <fmt>markdownmarkdown (for a sticky PR comment) or json (CoverageComparison, comparisonVersion: 1).
--out <file>stdoutWrite to a file instead.
--report-url <url>noneURL of the published HTML report: view names link to it.
--title <text>UI coverageThe heading.

summary ​

Print the markdown summary of one run (the same as githubSummary writes), e.g. for a PR comment when there's no base run to compare with:

bash
npx playwright-ui-coverage summary [ui-coverage-report/coverage.json] [--out file] [--report-url <url>] [--title <text>]

It takes --out, --report-url and --title like compare.

Released under the MIT License.