Mastering Playwright: Running Multiple Test Tags Simultaneously

Efficiently Executing Diverse Test Suites with Tag-Based Organization

·

1 min read

Mastering Playwright: Running Multiple Test Tags Simultaneously

Let's consider you're managing two distinct sets of tests, each uniquely tagged — one set with @Prod-UI and the other with @PR-push, without any overlap between them.

Question: How can you execute tests from both tags using a single command?

Solution: To run both sets of tests in a single command, one can use the following syntax:

yarn test:pw --grep "@Prod-UI | @PR-push"

Here's a breakdown of the command:

  • yarn test:pw initiates the test command.

  • --grep "@Prod-UI | @PR-push" filters the tests to include only those with the @Prod-UI tag or the @PR-push tag.

Additionally, the yarn test:pw command is configured as follows:

ALLURE_RESULTS_DIR=e2e/allure-results playwright test e2e --headed 
--config e2e/pw.local.config.ts

This configuration sets the directory for Allure test results, runs the tests in a headed mode (with a visible browser), and specifies the test configuration file to use.