What are the steps to set up a new test project in Playwright?


Setting Up a New Test Project in Playwright

First, create a configuration file named playwright.config.ts in your project's root directory. This file will specify the projects you want to run.

// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';

const config: PlaywrightTestConfig = {
  // Global options
  use: {
    // Set global options here

  // Define projects
  projects: [
      name: 'Chromium',
      use: { browserName: 'chromium' },
      name: 'Firefox',
      use: { browserName: 'firefox' },

export default config;

In this file, you can define multiple projects, specifying their name and the browser they will use for testing. You can also set global options such as timeouts or ignoring HTTPS errors using the use property.

To run tests on both desktop and mobile versions of a browser, specify different devices for each project.

Once your configuration file is ready, run your tests with npx playwright test. By default, Playwright runs all defined projects in parallel using multiple workers.

If you want to run a single project or specify other command line options, pass them in when running npx playwright test.

For more information on setting up and running tests in Playwright, check out Mastering Playwright Test Automation: Your Comprehensive Cheat Sheet.


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 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.