playwright-ast-coverage
v0.6.0
Published
Static Playwright AST coverage for Next.js App Router routes
Readme
playwright-ast-coverage
Static Playwright AST coverage for Next.js App Router projects.
playwright-ast-coverage helps teams and coding agents see which routes and
test-hook selectors are not exercised by Playwright tests. It scans source code
statically, so it is fast enough for local checks, CI guardrails, and agent
handoffs.
It is a heuristic coverage tool for Playwright/App Router workflows, not a replacement for runtime code coverage.
Install
npm install --save-dev playwright-ast-coverage
npx playwright-ast-coverage checkThe npm package downloads the matching native binary from GitHub Releases during postinstall. Unsupported platforms can install from Cargo:
cargo install playwright-ast-coverageWhy Use It
- Find App Router pages that no Playwright test visits.
- Find
data-testidanddata-pwhooks that tests never assert. - Ask for related tests when a page or component changes.
- Give AI agents a deterministic pre-finish coverage check.
playwright-ast-coverage check --json
playwright-ast-coverage related 'web/app/users/[id]/page.tsx'
playwright-ast-coverage edges --jsonConfigure
Create .playwright-ast-coverage.yaml, .playwright-ast-coverage.yml,
.playwright-ast-coverage.json, or .playwright-ast-coverage.jsonc when your
app is not under the default app directory or when selectors live in shared
component folders:
frontendRoot: web/app
playwrightConfig: playwright.config.ts
navigationHelpers:
- navigateTo
selectorAttributes:
- data-testid
- data-pw
componentSelectorAttributes:
dataPw: data-pw
htmlIds: true
selectorRoots:
- web/app
- web/components
selectorExclude:
- "**/*.test.tsx"
- "**/*.stories.tsx"