To run tests in parallel with @playwright/test, you can choose from several options. By default, tests in a single file run in order. If you want to run independent tests in parallel within a file, use the
test.describe.configure() method and set the mode to 'parallel'. Keep in mind that parallel tests run in separate worker processes and can't share state or global variables. Each test executes its own hooks, including
You can also enable fully-parallel mode for all tests by setting
fullyParallel: true in the
playwright.config.ts file. To enable fully-parallel mode for specific projects, add it under the
Each worker process gets two IDs: a unique worker index starting from 1 and a parallel index between 0 and
workers - 1. When a worker restarts, it keeps the same
parallelIndex but gets a new
workerIndex. Access these indices through
If you disable parallelism, tests run alphabetically by default. Control test order by naming files alphabetically or using a "test list" file. Soft assertions let you make checks that won't stop the test when failed but display a list of failed assertions at the end.
In short, @playwright/test offers multiple ways to run tests in parallel, such as enabling fully-parallel mode or controlling test order through naming conventions or "test list" files, while using soft assertions to continue testing despite failed checks.
If you still have questions, please ask a question and I will try to answer it.
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email firstname.lastname@example.org.