Rayrun
← Back to Discord Forum

Parallel execution is not working when we run tests in Azure pipeline

sandeep_33083posted in #help-playwright
Open in Discord
sandeep_33083

Hi All, We are trying to run tests as part of build definition, we see that all tests are executed one by one when we run in pipeline . (Only 1 worker is being used while running) Same tests when we run in local machine tests are running in parallel (in our case 2 workers are being used).

How to make tests run in parallel when running in pipeline, could someone help me in addressing this issue.

This thread is trying to answer question "How to make tests run in parallel when running in Azure pipeline?"

11 replies

What does your playwright.config.ts look like?

You should have something like this in the top for CI:

testDir: './tests',
    /* Run tests in files in parallel */
    fullyParallel: true,
    /* Fail the build on CI if you accidentally left test.only in the source code. */
    forbidOnly: !!process.env.CI,
    /* Retry on CI only */
    retries: process.env.CI ? 2 : 0,
    /* Opt out of parallel tests on CI. */
    workers: process.env.CI ? 2 : undefined,
    /* Reporter to use. See https://playwright.dev/docs/test-reporters */
    reporter: [
        [process.env.CI ? 'dot' : 'list'],
        [process.env.CI ? 'dot' : 'html', { open: 'never' }],
        ['junit', { outputFile: 'results.xml' }],
    ],

fullyParallel and workers being the important part.

If you have that already and it is not working, you are most like not setting process.env.CI in the pipeline.

- script: pnpm run test
      displayName: 'pnpm test'
      env:
          CI: true
sandeep_33083
@.gleedo: Hi, We tried to use whatever was specified above, still it is behaving same. When we run tests in local it is using multiple workers but when we run same tests in build definition it was running sequentially (running with single worker). Tested same with sample play wright project, we see same results with the sample project also. Sample project with which we tested is posted at "https://github.com/bejugamSandeep/PlayWritght", Could you please check and let me know what can be done. Yaml file which we are using for pipeline also posted to same location.

Hi, We tried to use whatever was specified above, still it is behaving same. When we run tests in local it is using multiple workers but when we run same tests in build definition it was running sequentially (running with single worker).

Tested same with sample play wright project, we see same results with the sample project also. Sample project with which we tested is posted at "https://github.com/bejugamSandeep/PlayWritght", Could you please check and let me know what can be done. Yaml file which we are using for pipeline also posted to same location.

Your playwright.config.ts in the repo has only 1 worker. That is the problem.

sandeep_33083
@.gleedo: Updated "workers: process.env.CI ? 1 : undefined" this line in the config file with following ways, 1) "workers: process.env.CI ? 10 : undefined" 2) "workers: process.env.CI ? undefined : undefined" 3) Removed this line from config file With all above cases it was using only 1 worker. Please let me know if I am missing anything here.

Updated "workers: process.env.CI ? 1 : undefined" this line in the config file with following ways,

  1. "workers: process.env.CI ? 10 : undefined"
  2. "workers: process.env.CI ? undefined : undefined"
  3. Removed this line from config file

With all above cases it was using only 1 worker. Please let me know if I am missing anything here.

Try just workers: 10

undefined defaults to 1 probably

and azure does not set ci env variable hence 1) didn’t work either

sandeep_33083
@skorp32: Its working, Thank you.

Its working, Thank you.

If I use undefined, it uses the maximum number of workers my machine can handle.

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