CircleCI

Running Playwright Tests in Parallel on CircleCI and Currents

circle-info

Run Playwright tests in parallel on CircleCIarrow-up-right using the native Playwright Shardingarrow-up-right to split the tests between multiple containers. Parallelizing the test will help in decreasing the overall run duration.

Currents collects the results of distributed parallel CircleCI builds for more efficient troubleshooting. Each container will receive a unique set of tests to run so that your tests will run faster and you can receive faster feedback from your browser test suite.

Create multiple containers that will run your tests in parallel by setting the desired amount of containers with parallelismarrow-up-right flag in config.yaml file.

Please refer to the example repositoryarrow-up-right demonstrating how to set up CircleCIarrow-up-right for running Playwright tests in parallel using Currentsarrow-up-right service.

# .circleci/config.yml
version: 2.1
jobs:
  run-test:
    docker:
      - image: mcr.microsoft.com/playwright:latest
    # Enable parallelism of 3
    parallelism: 3
    steps:
      - checkout
      - run: npm i -D @playwright/test
      - run: npx playwright install
      - run: npx playwright install chrome
      - run:
          name: Run tests
          # Enable Playwright Shards
          # - Use CURRENTS_RECORD_KEY secret from context
          # - Grab Project ID from https://app.currents.dev
          command: SHARD="$((${CIRCLE_NODE_INDEX}+1))"; npx pwc --key $CURRENTS_RECORD_KEY --project-id bnsqNa --shard=${SHARD}/${CIRCLE_NODE_TOTAL}

# Invoke jobs via workflows
workflows:
  run-test-workflow:
    jobs:
      - run-test:
          # Use "currents" CircleCI context to enable access to secrets
          context: currents

The example config filearrow-up-right:

  • runs 3 containers with Playwright tests in parallel

  • Note: use CLI arguments to customize your cypress runs, e.g.: pwc run --key <your Currents.dev key>

Last updated

Was this helpful?