What is the process of organizing and running multiple test files in Playwright using the 'projects' option in the configuration file?


Managing Multiple Test Files with Playwright

With Playwright, you can manage multiple test files using the projects option in the configuration file. This allows you to define different projects with their own properties and settings.

Here's how you can do it:

Define Projects in Configuration File

In your playwright.config.ts file, define each project within the projects array. Each project is an object with properties like name, testMatch, testIgnore, and retries.

import { defineConfig } from '@playwright/test';

export default defineConfig({
  timeout: 60000,
  projects: [
      name: 'Smoke',
      testMatch: /.*smoke.spec.ts/,
      retries: 0,
      name: 'Default',
      testIgnore: /.*smoke.spec.ts/,
      retries: 2,

In this example, the "Smoke" project includes all test files matching /.*smoke.spec.ts/ with no retries. The "Default" project includes all other test files with a retry count of 2.

Run the Tests

To run the tests, use the --project flag followed by the project name.

npx playwright test --project=Smoke
npx playwright test --project=Default

This will run only the tests associated with the specified project.

By using projects in your configuration file and the --project flag, you can effectively manage and run multiple test files with different configurations.


Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

Related Discord Threads

Related Questions

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

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 luc@ray.run.