๐ฃ๐ฎ๐ฟ๐ฎ๐น๐น๐ฒ๐น๐ถ๐๐บ ๐๐ป๐ฑ ๐๐น๐ฎ๐ธ๐ฒ ๐๐ผ๐ป๐๐ฟ๐ผ๐น ๐ถ๐ป ๐ฃ๐น๐ฎ๐๐๐ฟ๐ถ๐ด๐ต๐
Parallel tests are fast. But they bring flakiness. Playwright uses workers. Workers are separate processes. Playwright isolates the browser for each test. Cookies and cache stay separate.
The browser is isolated. Your backend is not. Shared data causes flakiness.
Four common reasons for flakes:
- Shared state. Tests reset data while others read it. Fix: Seed data once.
- Weak locators. Tests match the wrong text. Fix: Use exact matches.
- App races. Tests move before the page loads. Fix: Wait for a signal.
- Data collisions. Two tests use the same title. Fix: Use unique data.
Ways to stop flakiness:
- Turn on fullyParallel for speed.
- Use serial mode for tests requiring a specific order.
- Set project dependencies to order your phases.
- Create unique data for every test.
Retries are a last resort. They hide flakes. They do not fix bugs.
Find flakes by running tests many times. Use the repeat-each flag. Use traces to see the failure.
Star the repo to follow along. Tell me about the last flaky test you found.
Source: https://dev.to/aktibaba/parallelism-flake-control-playwright-typescript-ch19-b9n Optional learning community: https://github.com/aktibaba/playwright-qa-course