Skip to content

Latest commit

 

History

History
57 lines (45 loc) · 3.08 KB

File metadata and controls

57 lines (45 loc) · 3.08 KB
description Running Playwright Tests in Parallel on CircleCI and Currents

CircleCI

{% hint style="info" %} TL;DR Check out the example repository:

https://github.com/currents-dev/currents-examples {% endhint %}

Run Playwright tests in parallel on CircleCI using the native Playwright Sharding 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 the parallelism key in the .circleci/config.yml file.

Please refer to the example repository demonstrating how to set up CircleCI for running Playwright tests in parallel using Currents service.

# .circleci/config.yml
version: 2.1
jobs:
  run-test:
    docker:
      - image: space.vars.PW_IMAGE_ROUTE + ":" + space.vars.LATEST_PW_IMAGE_VERSION
    # 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
          # - Add CURRENTS_RECORD_KEY and CURRENTS_PROJECT_ID to the "currents" CircleCI context
          command: SHARD="$((${CIRCLE_NODE_INDEX}+1))"; npx pwc --key "$CURRENTS_RECORD_KEY" --project-id "$CURRENTS_PROJECT_ID" --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 file:

  • runs 3 containers with Playwright tests in parallel
  • Note: the Run tests step above is ready to run once the currents context defines CURRENTS_RECORD_KEY and CURRENTS_PROJECT_ID (from app.currents.dev); you can append other pwc flags as needed.