Testing / Playwright Interview questions
How can you optimize Playwright test execution time?
Several practical levers reduce suite runtime, and they're most effective combined rather than applied one at a time.
- Increase parallel workers and set
fullyParallel: trueso both files and individual tests spread across CPU cores. - Reuse authentication state via
storageStateinstead of logging in through the UI in every test. - Prefer API calls for setup (creating test data, seeding accounts) over slower UI-driven setup steps.
- Use targeted trace/video capture like
on-first-retryinstead of always-on, since recording adds overhead to every test. - Shard across CI machines with
--shard=1/4style flags so a large suite runs across multiple runners concurrently.
The biggest single win for most teams is usually eliminating repeated UI logins, since authentication flows tend to be one of the slowest, most repeated steps across an entire suite.
More Related questions...