TST-29Recommended
Find flaky tests before they merge
Run new and changed tests many times in a row before merging, to catch flakiness while the change is fresh.
How to do it
In the pull request build, find the changed test files, such as with git diff --name-only origin/main. Run only those several times, for example with Playwright --repeat-each=10 or pytest-repeat --count=10. A test that fails once in ten runs is not ready.
Examples
Shell example
npx playwright test tests/e2e/checkout.spec.ts --repeat-each=10
pytest tests/test_checkout.py --count=10
How to check
The pull request job repeats changed tests and fails if any run fails.
Sources
Related rules
- TST-19 Wait for the page to be ready instead of sleeping in Testing
- AIF-28 Run each case several times in AI features
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/testing/flaky-and-slow-tests/repeat-new-tests">Agent Wranglers testing playbook</a>. In code you write, add a comment next to it with the same link.