Parallel Test Execution | Bondar Academy
Course: Playwright UI Testing with TypeScript
Module: Advanced Tricks and Techniques
Instructor: Artem Bondar
Lesson Summary
Parallel Execution in PlayWrite In this lesson, we explore how PlayWrite handles parallel execution of tests. By default, PlayWrite runs spec files in parallel, creating a new instance of the web browser, known as a Worker , for each spec file. Key Concepts Workers: Each spec file is executed in a separate Worker. For example, with five spec files, PlayWrite creates five Workers to run tests in parallel. Fully Parallel: This setting determines if tests within a single spec file run in parallel. If set to true , tests run concurrently; if false , they run sequentially. Configuration Settings Two main settings in PlayWriteConfig.ts are: Workers: Configured to control the number of Workers. Setting it to 1 disables parallel execution. Fully Parallel: Set to true to enable parallel execution within a spec file. Execution Examples When executing tests: With five Workers and fully parallel set to true , tests completed in 10.3 seconds. With one Worker, tests took 29 seconds, running sequentially. Spec Level Configuration You can configure parallel execution at the spec level: Use test.describe.parallel to run specific tests in parallel. Use test.describe.configure({ mode: 'serial' }) for tests that depend on each other. In summary, PlayWrite allows flexible configurations for parallel execution, enhancing test efficiency while providing control over execution order and dependencies.