Rayrun
← Back to Discord Forum

Bitbucker paralelization

Did anyone managed to make playwrigth paralelization in bitbucket pipelines? I am planning to run lets say 5 instances of the app and I would like to run the tests from the bitbucket in paralelization.

This thread is trying to answer question "How can Playwright parallelization be implemented in Bitbucket pipelines?"

0 replies

Answer

Implementing Playwright Parallelization in Bitbucket Pipelines

To start, you'll need to use the public Docker image provided by Playwright: mcr.microsoft.com/playwright:v1.35.0-jammy. This image has all the dependencies you need to run Playwright tests.

In your Bitbucket Pipelines configuration file, specify the Playwright Docker image as the build environment using the image keyword:

image: mcr.microsoft.com/playwright:v1.35.0-jammy

Next, define a stage for running your Playwright tests, like "e2e-tests". You can use the sh command to execute shell commands:

stages:
  - e2e-tests

pipelines:
  default:
    - step:
        name: Run Playwright Tests
        script:
          - sh 'npm ci'
          - sh 'npx playwright test'

By default, your tests will run sequentially. To enable parallelization and split your tests into smaller jobs that run in parallel, use Bitbucket Pipelines' support for parallel execution.

Add a parallel keyword under the tests section of your pipeline configuration to specify how many parallel jobs should be created:

pipelines:
  default:
    - step:
        name: Run Parallelized Playwright Tests
        script:
          - sh 'npm ci'
          - sh 'npx playwright test --shard=$BITBUCKET_PARALLEL_STEP/$BITBUCKET_PARALLEL_TOTAL'

Bitbucket Pipelines automatically sets the $BITBUCKET_PARALLEL_STEP and $BITBUCKET_PARALLEL_TOTAL environment variables when running in parallel mode. Each job will have a unique value for $BITBUCKET_PARALLEL_STEP, ranging from 1 to the total number of parallel jobs specified by $BITBUCKET_PARALLEL_TOTAL. You can use this value in your Playwright test command to shard the tests accordingly.

For more details on maximizing test efficiency with parallelism in Playwright, check out this blog post.

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.