> For the complete documentation index, see [llms.txt](https://docs.currents.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.currents.dev/getting-started/ci-setup/playwright-circleci.md).

# CircleCI

Running Playwright Tests in Parallel on CircleCI and Currents

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

[https://github.com/currents-dev/currents-examples](https://github.com/currents-dev/currents-examples/tree/main/playwright/ci/circleci)
{% endhint %}

Run Playwright tests in [parallel on CircleCI](https://circleci.com/docs/guides/optimize/parallelism-faster-jobs/) using the native [Playwright Sharding](https://playwright.dev/docs/test-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`](https://circleci.com/docs/reference/configuration-reference/#parallelism) key in the `.circleci/config.yml` file.

Please refer to the [example repository](https://github.com/currents-dev/currents-examples/tree/main/playwright/ci/circleci) demonstrating how to set up [CircleCI](https://circleci.com) for running Playwright tests in parallel using [Currents](https://currents.dev) service.

* Create an organization at <https://app.currents.dev>
* Create a new project
* Grab `CURRENTS_RECORD_KEY` [Record Key](/guides/record-key.md) and `CURRENTS_PROJECT_ID`
* Store `CURRENTS_RECORD_KEY`: <https://circleci.com/docs/guides/security/contexts/>

The config below assumes the repository already reports to Currents locally, as set up in [Quick Start](/getting-started/your-first-playwright-run.md), so `npm install` installs `@playwright/test` and `@currents/playwright` from `package.json`.

<pre class="language-yaml"><code class="lang-yaml"># .circleci/config.yml
version: 2.1
jobs:
  run-test:
    docker:
      - image: <code class="expression">space.vars.PW_IMAGE_ROUTE + ":" + space.vars.LATEST_PW_IMAGE_VERSION</code>
    # Enable parallelism of 3
    parallelism: 3
    steps:
      - checkout
      - run: npm install
      - 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
</code></pre>

The example [config file](https://github.com/currents-dev/currents-examples/blob/main/playwright/ci/circleci/.circleci/config.yml):

* 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](https://app.currents.dev)); you can append other `pwc` flags as needed.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.currents.dev/getting-started/ci-setup/playwright-circleci.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
