← tools

playwright-affected

stable

Maps a PR's git diff to one --grep. Runs the full suite whenever it cannot decide.

937 downloads/mo · 6 stars

npm i -D playwright-affected
GitHubnpmReleases

Problem

Run the Playwright tests your PR affects, or the full suite when it cannot tell. Selection is change-based: the PR's git diff decides what runs.

How it works

  • Maps the PR's git diff to tags, test paths and Playwright projects, and emits one --grep.
  • Each changed file is checked against the map in a fixed order; the first step that matches decides.
  • A global trigger, an unmapped source file, an empty diff, an empty selection, a map entry that matches no test, or any tool error runs the full suite.
  • replay scores a map against merged PRs. shadow counts the failures a selection would have missed.

Requirements

Node 22.5 or newer and git. replay also needs an authenticated gh CLI. Tested with Playwright 1.64. Works in any CI.

FAQ

What happens when it cannot decide?
It runs the full suite. select exits 0 on that fallback, 2 on bad arguments and 1 if it cannot write --out.
Where should selection run in CI?
On PRs only. Keep the full suite on the merge queue or default branch, and on a schedule. select needs the base ref's history, so use fetch-depth: 0 or fetch the base branch.
How do I check a map before making it blocking?
Keep running the full suite on PRs, add Playwright's json reporter and record shadow for each PR.
Can a PR change its own selection?
Yes. The map is read from the PR branch. The full suite on the merge queue is the safety net.
Does it work on Windows?
Path-based selection assumes / separators. On Windows, Playwright matches test paths with a backslash, so tests prefixes do not match.