Rayrun
← Back to Discord Forum

Serial Mode

Hey guys i need help, I have a test file that's in serial mode, i only test chrome browser in it, now i want to test it in other browsers (e.g. Firefox)

test.describe.configure({ mode: 'serial' });

works fine,

but only for the current browser so basically 1 worker for each browser if i enable firefox then total workers is 2

i want it to wait for chrome to finish then test starts in other browsers, i want to keep 1 worker only for the test file, i can achieve it in the config by setting it to 1, but i can't since i'm running parallel tests in other test files.

How can i achieve it? is there a way to set 1 worker only in a test file?

This thread is trying to answer question "How can I set a single worker for a test file in Playwright when other test files are running in parallel?"

3 replies
dirvinautomation_16636

You can explicitly set the workers to 1 either in your config, or in the command that runs the test.

In playwright.config.ts:

export default defineConfig({
  workers: 1,
})

or in the command line:

npx playwright test path/to/test.spec.ts --workers=1

EDIT: I guess you can ignore me, I missed this line: "is there a way to set 1 worker only in a test file?"

I think refactoeric is on the right idea

Having multiple workers for some tests and a single worker for others is complicated.

Option A: Create two separate config files, and run npx playwright test multiple times (in succession), passing the config file with the -c option.

Option B: Use project dependencies to control the order of execution: https://playwright.dev/docs/test-projects#dependencies But this option is only acceptable if you have very few tests that need to run one by one (without parallelism), because you'd need to define a project per serial spec file.

With dependencies looking like project parallelTests Webkit depends on serialTest Webkit project parallelTests Firefox depends on serialTest Webkit project parallelTest Chromium depends on serialTest Webkit project serialTest Webkit depends on serialTest Firefox project serialTest Firefox depends on serialTest Chromium project serialTest Chromium depends on nothing (or depends on setup)

So it's awkward if you want some tests to run in parallel and some running exclusively. Maybe you can avoid it by redesigning the test scenarios and test data to not collide with each other?

I face the same issue. As I understand there isn't a good solution for now. There is a feature request for setting number of workers per project. You can upvote it here: https://github.com/microsoft/playwright/issues/18950

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