Menu

1 / 5

Running Only the Affected Playwright Tests on a Pull Request: 4 Bugs That Exited 0

DEV Community: github·Gary Parker·7 days ago
#SQkREM12
#devtogithub#technology#devto#dev#tests
Long article (1820 words) — no AI summary yet.
Reading 0:00
15s threshold

Playwright can run only the tests a pull request changed, with one flag. On 8 seeded pull requests against a 12-test suite, --only-changed caught 13 of the 27 tests the bugs broke. In 5 of the 8 pull requests it ran 0 tests, printed nothing and exited 0. 4 of those 5 had a bug that failed between 1 and 9 tests on the full suite.

This guide sets up both ways to run only the affected tests on a pull request: Playwright's --only-changed , and a map with playwright-affected , a tool I maintain. The map caught 27 of 27 and ran 67 of the 96 tests the full suite ran. The shop, the tests, the map, the workflow and the raw output of every run are in the PoC repo .

The suite

A small static shop in app/ : search, cart and checkout in three JavaScript files, a stylesheet, and a static file server that Playwright starts with webServer .

12 tests in 4 spec files, one tag per file: @search (3), @cart (3), @checkout (4) and @smoke (2).

The search, cart and checkout specs use page objects in tests/pages/ .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.