Rayrun
← Back to Discord Forum

Playwright.config.ts/How to run projects one by one?

oleksiyluchposted in #help-playwright
Open in Discord

I have 3 projects in playwright.config.ts file and i have to run projects one by one because i have different DB setting for each on it.

This thread is trying to answer question "How can I run multiple projects one by one in a playwright.config.ts file due to different database settings for each project?"

4 replies
@butchmayhew: If I use this way the reports will be overwritten and I will only get the latest one

If I use this way the reports will be overwritten and I will only get the latest one

@oleksiyluch u can configure ur projects in package.json n then u can run one after the other

@oleksiyluch: You could save the resort off to a different directory and push the results before kicking off the next project run.

You could save the resort off to a different directory and push the results before kicking off the next project run.

Answer

Sure, you can run individual projects with unique database configurations in a playwright.config.ts file using the --project command line option.

Here's how you can define multiple projects in your playwright.config.ts file:

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

export default defineConfig({
  projects: [
    {
      name: 'Project 1',
      use: {
        baseURL: 'https://ray.run',
        databaseSettings: {
          host: 'localhost',
          port: 3306,
          username: 'user1',
          password: 'password1',
        },
      },
    },
    {
      name: 'Project 2',
      use: {
        baseURL: 'https://ray.run',
        databaseSettings: {
          host: 'localhost',
          port: 5432,
          username:'user2',
          password:'password2'
        },
      },
    },
  ],
});

To run a specific project, use the --project command line option followed by the project name:

npx playwright test --project="Project 1"

This command will run only the tests for "Project 1" with its specific configuration and database settings.

To run "Project 2", use:

npx playwright test --project="Project 2"

By using the --project option, you can run the projects one by one with their respective database settings. This allows you to test different environments or configurations without affecting other projects. Remember to replace "Project 1" and "Project 2" with your actual project names.

Related Discord Threads

TwitterGitHubLinkedIn
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 [email protected].