> This is part 1 of 3 of the full documentation (pages 1–100 of 266).
> The content is paginated: fetch every part to see all of it.
> Next part: https://docs.currents.dev/llms-full.txt/1
> Page index: https://docs.currents.dev/llms.txt

# 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
This site has an agentic ask interface you may use to query the documentation dynamically 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/index.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.

---

# Overview

Currents is a cloud platform, dashboard and test orchestrator aimed to help SDET and Software Teams to manage the complexity of running automated tests in CI.

**Currents goes beyond test reports** to help teams understand test health, reduce CI runtime, and keep large test suites reliable.

SDETs, QA engineers, and engineering leaders, from startups to large enterprises, use Currents to fix CI failures faster, control flakiness, and scale testing across teams and repositories.

## Get started

Follow our quickstart guide to connect Playwright to Currents. To connect your CI provider, follow our **Setup your CI provider** guide.

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-card-cover data-type="files"></th></tr></thead><tbody><tr><td><ol><li>Quickstart</li></ol></td><td><a href="https://docs.currents.dev/getting-started/your-first-playwright-run">Quick Start</a></td><td><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FRBP06Abkev8QEAJLR6o0%2Fhuge-playwright.png?alt=media&amp;token=cc6e36a9-b97e-4b2c-86d3-f44fb35dfe09">huge-playwright.png</a></td></tr><tr><td><ol start="2"><li>Setup your CI provider</li></ol></td><td><a href="https://docs.currents.dev/getting-started/ci-setup">CI Setup</a></td><td><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FfiAvHKPGpQCrwLgOg1al%2Fci-providers.png?alt=media&amp;token=70de6205-e468-4955-8c56-c0a66764c1ae">ci-providers.png</a></td></tr></tbody></table>

## Why Currents

Playwright reports explain a single run.\
Currents explains your test suite over time, and more.

As teams scale testing in CI, they need visibility into debugging traces, flakiness, regressions, and performance trends, and ways to act on them. Currents aggregates test data across runs and repositories, optimizes CI execution, integrates across your delivery stack, and brings test intelligence directly into daily engineering workflows.

{% content-ref url="/pages/qb47rb1B2Vi3OGRuRS1M" %}
[Alternatives to Currents](https://docs.currents.dev/resources/reporters/alternatives-to-currents)
{% endcontent-ref %}

## AI Onboarding

Currents turns test failures into structured context that AI agents can act on - full errors, traces, historical results, and flakiness data - so an agent fixes a failing test from real evidence instead of a pasted error message. Debug interactively in your editor, hand failures to an agent from the dashboard, or build pipelines that auto-heal failing tests.

<table><thead><tr><th width="280" data-type="content-ref">AI</th><th></th></tr></thead><tbody><tr><td><a href="https://docs.currents.dev/ai/overview">Overview</a></td><td>All the ways to connect AI agents to your test results.</td></tr><tr><td><a href="https://docs.currents.dev/ai/connect/ide-extension">IDE Extension</a></td><td>Fix CI failures with AI without leaving your editor.</td></tr><tr><td><a href="https://docs.currents.dev/ai/connect">Connect your agent</a></td><td>Connect Claude, ChatGPT, Codex or any MCP client to Currents.</td></tr><tr><td><a href="https://docs.currents.dev/ai/reference/mcp-server">MCP tools and permissions</a></td><td>Let agents query runs, tests, and analytics on demand.</td></tr><tr><td><a href="https://docs.currents.dev/ai/agent-skills/agent-skill-playwright-best-practices">Playwright best practices</a></td><td>Expert Playwright knowledge for your AI agents.</td></tr></tbody></table>

## Explore

Currents is much more than a reporter. Discover the full range of features and capabilities.

<table><thead><tr><th width="280" data-type="content-ref">Debugging &#x26; Analytics</th><th></th></tr></thead><tbody><tr><td><a href="https://docs.currents.dev/dashboard/tests">Tests</a></td><td>Debug failures with full execution history.</td></tr><tr><td><a href="https://docs.currents.dev/dashboard/analytics">Analytics</a></td><td>See flakiness, regressions, and trends over time.</td></tr><tr><td><a href="https://docs.currents.dev/dashboard/test-suite-performance-explorer">Test Suite Explorer</a></td><td>Discover problematic tests.</td></tr><tr><td><a href="https://docs.currents.dev/guides/coverage">Code Coverage</a></td><td>Track test coverage over time.</td></tr></tbody></table>

<table><thead><tr><th width="280" data-type="content-ref">Speeding up CI</th><th></th></tr></thead><tbody><tr><td><a href="https://docs.currents.dev/guides/ci-optimization">CI Optimization</a></td><td>Shorten pipelines without sacrificing coverage.</td></tr><tr><td><a href="https://docs.currents.dev/guides/test-orchestration">Test Orchestration</a></td><td>Distribute tests across CI jobs. Faster than Sharding.</td></tr></tbody></table>

<table><thead><tr><th width="280" data-type="content-ref">Automation</th><th></th></tr></thead><tbody><tr><td><a href="https://docs.currents.dev/guides/currents-actions">Currents Actions</a></td><td>Automatically alert, skip or quarantine tests.</td></tr><tr><td><a href="https://docs.currents.dev/dashboard/automated-reports">Automated Reports</a></td><td>Proactively identify regressions.</td></tr><tr><td><a href="https://docs.currents.dev/resources/integrations">Integrations</a></td><td>Integrate with issue tracking and collaboration tools.</td></tr></tbody></table>


# Quick Start

Running Playwright tests with Currents Dashboard

Connect Playwright to Currents in a few minutes and start seeing runs, screenshots, videos, and traces in one place. This guide keeps the setup minimal so you can go from "tests run locally" to "results show up in Currents" without extra ceremony.

## Prerequisites <a href="#prerequisites" id="prerequisites"></a>

* An account - [sign up](https://app.currents.dev/signup) for a free trial.
* Node.js 20.18.1+, or Bun with Playwright 1.65.0+. See [Compatibility Guide](https://docs.currents.dev/resources/reporters/currents-playwright/compatibility#run-playwright-with-bun).
* Playwright v1.40.1+ works well.
  * If you're using Playwright v1.60.0+ you'll require `@currents/playwright` 2.0.0+, see [Compatibility Guide](https://docs.currents.dev/resources/reporters/currents-playwright/compatibility).

{% hint style="info" %}
To have a coding agent do the setup, see [Set Up with an AI Agent](https://docs.currents.dev/getting-started/setup-with-an-agent).
{% endhint %}

## Setup Currents

{% stepper %}
{% step %}

#### Create a Project

After you sign up, Currents asks you to name your organization and answer a few questions about your team. Then create your first project: the name is taken from your organization name, and you can change both later. Click **Create project and show me the setup**.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-47ba278f5505607885498235366e1c79a8bc80ff%2Fcreate-first-project.png?alt=media" alt="The first project form: a project name field and a button that opens the setup instructions"><figcaption></figcaption></figure>

The setup page opens on **Local Setup**. Select Playwright as the testing framework. **Project Credentials** shows your `Project ID` and `Record Key`. Keep that page open for the next steps.
{% endstep %}

{% step %}

#### Install @currents/playwright

Install the native Playwright reporter with your project's package manager.

```bash
npm i -D @currents/playwright
```

If you use `pnpm`, `yarn`, or `bun`, run the equivalent dev dependency install command instead.
{% endstep %}

{% step %}

#### Create currents.config.ts

Create `currents.config.ts` next to `playwright.config.ts`, usually in the project root. If your Playwright config uses `.js` or `.mjs`, use that same extension for `currents.config`, and remove the type import and the `!`.

{% code title="currents.config.ts" %}

```typescript
import { CurrentsConfig } from "@currents/playwright";

const config: CurrentsConfig = {
  recordKey: process.env.CURRENTS_RECORD_KEY!,
  projectId: process.env.CURRENTS_PROJECT_ID!,
};

export default config;
```

{% endcode %}

{% hint style="warning" %}
Set `CURRENTS_PROJECT_ID` and `CURRENTS_RECORD_KEY` to the values from Currents. Keep the Record Key out of files you commit.
{% endhint %}
{% endstep %}

{% step %}

#### Enable artifacts

Update `playwright.config.ts` so every recorded run includes traces, videos, and screenshots.

```typescript
use: {
    // ...
    trace: "retain-on-failure-and-retries",
    video: "retain-on-failure",
    screenshot: "on",
}
```

These artifacts are what make the dashboard useful from the first run, so it is worth enabling all three up front.
{% endstep %}

{% step %}

#### Setup Currents Reporter

You have two ways to finish the integration:

{% hint style="info" %}
Most teams should start with the **Currents Reporter** because it keeps the existing Playwright command unchanged.
{% endhint %}

<details>

<summary>Option 1: Add Currents Reporter (recommended)</summary>

Add the Currents reporter to `playwright.config.ts` and keep using `playwright test`.

```typescript
// playwright.config.ts
import { defineConfig, devices, PlaywrightTestConfig } from "@playwright/test";
import { currentsReporter } from "@currents/playwright";

export default defineConfig({
  // ...
  reporter: [currentsReporter()], // 👈🏻 add Currents reporter
})
```

If you already have reporters configured, keep them and append `currentsReporter()` to the list.

* Run `npx playwright test` or your usual test command to start sending results to Currents.
* The reporter reads settings from `currents.config.ts`. See [@currents/playwright](https://docs.currents.dev/resources/reporters/currents-playwright) for more configuration options.

</details>

<details>

<summary>Option 2: Run tests with the pwc command</summary>

`pwc` is a lightweight command-line executable included in `@currents/playwright`. It runs Playwright with Currents wired in for you.

Setup

* Run `npx pwc`.
* Or update `package.json` to execute `pwc` instead of `playwright test`.

```json
"scripts": {
  ...
  "test": "npx pwc",
},
```

How it works

* `pwc` reads the configuration from `currents.config.ts` file. See additional configuration options [Configuration](https://docs.currents.dev/resources/reporters/currents-playwright/configuration).
* `pwc` injects Currents reporter into Playwright configuration.
* You can also provide CLI configuration parameters, e.g. `npx pwc --key RECORD_KEY --project-id PROJECT_ID`

</details>
{% endstep %}
{% endstepper %}

## Create your first run

After setup, run Playwright and watch results get [streamed in real-time](https://docs.currents.dev/guides/parallelization-guide/step-level-reporting) to Currents. Here's the command for the same:

```bash
CURRENTS_PROJECT_ID=<project-id> CURRENTS_RECORD_KEY=<record-key> npx playwright test
```

{% hint style="info" %}
You can find both the `CURRENTS_PROJECT_ID` as well as the `CURRENTS_RECORD_KEY` in the Currents dashboard.
{% endhint %}

A link to the recorded run will be available at the start of the execution:

```
📦 Currents reporter: 2.5.1 recording to project WlKqJ0
🎭 Playwright: 1.63.0 5 tests in 1 project [chromium]
🌐 Run URL: https://app.currents.dev/run/cfc7ab8fcaaz10157
```

Open the link to see the run in the dashboard.

{% embed url="<https://player.mux.com/qpKec7RVobezySxuxI52G9bCt4vr2ffi4rNGqbm9Ab4?thumbnail-time=35>" %}

{% hint style="warning" %}
No run link, or the run doesn't show up? See [Missing Runs](https://docs.currents.dev/guides/missing-runs).
{% endhint %}

## Next Step

Once your Playwright project is set up and reporting locally, configure your CI pipeline.

Running tests in CI is where you get consistent, repeatable feedback on every pull request and deployment, not just on your local machine.

{% content-ref url="/pages/xHzwM6ZSoRz2XHnYqgTt" %}
[CI Setup](https://docs.currents.dev/getting-started/ci-setup)
{% endcontent-ref %}


# Set Up with an AI Agent

Set up Currents with Claude Code, Cursor, Codex or another coding agent, locally and in CI

Paste this prompt into your coding agent, in the repository with your tests:

```
Set up this repository to report test results to Currents. Read https://docs.currents.dev/getting-started/setup-with-an-agent.md and follow it.
```

To add Currents to CI in a repository that already reports from a local machine:

```
Add Currents to this repository's CI. Read https://docs.currents.dev/getting-started/setup-with-an-agent.md and follow the "Add Currents to CI" section.
```

The rest of this page is written for the agent. It points to the setup guide for each framework and adds the steps those guides leave to the reader.

## 1. Ask for the Project ID and Record Key

Ask the user for both values. Currents shows them right after the user creates a project. Later, the Project ID is in [Project Settings](https://docs.currents.dev/dashboard/projects/project-settings.md) and the Record Key is under **Record Keys** in the organization menu ([Record Key](https://docs.currents.dev/guides/record-key.md)).

Read both from environment variables: `CURRENTS_PROJECT_ID` and `CURRENTS_RECORD_KEY`. Where a guide writes a project ID or key into a file, use the environment variable instead. Never commit the Record Key.

## 2. Follow the guide for the framework

| Framework                                                     | How to tell                                | Guide                                                                                                                 |
| ------------------------------------------------------------- | ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------- |
| Playwright                                                    | `@playwright/test` in `package.json`       | [Quick Start](https://docs.currents.dev/getting-started/your-first-playwright-run.md)                                 |
| Jest                                                          | `jest` in `package.json`                   | [Your First Jest Run](https://docs.currents.dev/getting-started/other-frameworks/jest/your-first-jest-run.md)         |
| Vitest                                                        | `vitest` in `package.json`                 | [Your First Vitest Run](https://docs.currents.dev/getting-started/other-frameworks/vitest/your-first-vitest-run.md)   |
| Cypress                                                       | `cypress` in `package.json`                | [Your First Cypress Run](https://docs.currents.dev/getting-started/other-frameworks/cypress/you-first-cypress-run.md) |
| Node test runner                                              | `node --test` in the test script           | [@currents/node-test-reporter](https://docs.currents.dev/resources/reporters/currents-node-test-reporter.md)          |
| Anything that writes JUnit XML: WebdriverIO, Postman (Newman) | A JUnit reporter in the test configuration | [JUnit](https://docs.currents.dev/getting-started/other-frameworks/others.md)                                         |

Make every change the guide lists, using the repository's package manager. If the repository has more than one test suite, for example Playwright end-to-end tests and Jest unit tests, set up each one and run each one in step 3.

For Cypress, check the version first. Currents doesn't support Cypress 13 and later; see [Compatibility](https://docs.currents.dev/getting-started/other-frameworks/cypress/integrating-with-cypress/compatibility.md). Tell the user instead of changing their Cypress version.

## 3. Run the tests once

Run the tests with both variables set, for example:

```bash
CURRENTS_PROJECT_ID=<project-id> CURRENTS_RECORD_KEY=<record-key> npx playwright test
```

The run reached Currents when the output has a link to it:

* Playwright prints `Run URL: https://app.currents.dev/run/...` when the run starts.
* Jest, Vitest and JUnit print the link when `currents run upload` finishes.

Give the user the link. If there is none, follow [Missing Runs](https://docs.currents.dev/guides/missing-runs.md).

## Add Currents to CI

1. Find the CI provider from the repository files, such as `.github/workflows/`, `.gitlab-ci.yml`, `.circleci/config.yml`, `Jenkinsfile`, `azure-pipelines.yml`, `.buildkite/`, `buildspec.yml` (AWS CodeBuild) or `.harness/`.
2. Follow its guide from [CI Setup](https://docs.currents.dev/getting-started/ci-setup.md). For Jest and Vitest, use the CI Setup page under that framework.
3. Ask the user to store `CURRENTS_RECORD_KEY` as a CI secret and `CURRENTS_PROJECT_ID` as a CI variable or secret. Reference them by those names in the CI configuration.
4. If a guide's container image shows as an expression such as `space.vars.PW_IMAGE_ROUTE`, use `mcr.microsoft.com/playwright:v<version>-noble`, where `<version>` is the `@playwright/test` version in the repository.
5. After the user pushes the change, check that the CI log has the run link from step 3.

Secrets are not available to every job. In GitHub Actions, pull requests from forks get no secrets, so their runs don't reach Currents. [Missing Runs](https://docs.currents.dev/guides/missing-runs.md) lists the same limit for other providers.


# CI Setup

Learn how to integrate Currents with your CI provider.

## Get started

Integrating Currents with your CI Provider is the next logical step after creating your first run. Currents supports all major CI providers and provides examples for the most popular ones.

{% hint style="warning" %}
Got stuck configuring CI? Reach out to our [Support](https://docs.currents.dev/resources/support), we'll be happy to help!
{% endhint %}

## CI Providers

Below are articles guiding how to integrate with major CI Providers, with code examples included.

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-card-cover data-type="image">Cover image</th><th data-hidden data-card-cover-dark data-type="image">Cover image (dark)</th></tr></thead><tbody><tr><td><strong>GitHub Actions</strong></td><td></td><td><a href="https://docs.currents.dev/getting-started/ci-setup/github-actions/playwright-github-actions">Quick Start</a></td><td data-object-fit="contain"><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-c405c40f696b782a55f2d8c79d8c35a7d9b0f416%2Fgithub-mark.png?alt=media">github-mark.png</a></td><td data-object-fit="contain"><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-fe56dcf4024c1b4d4d79e8d2213778cc6549061e%2Fgithub-mark-white.png?alt=media">github-mark-white.png</a></td></tr><tr><td><strong>GitLab</strong></td><td></td><td><a href="https://docs.currents.dev/getting-started/ci-setup/gitlab/playwright-gitlab-ci-cd">Quick Start</a></td><td data-object-fit="contain"><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-3fd5b10da05dd2139c100cf4722f962b45e08831%2Fgitlab.svg?alt=media">gitlab.svg</a></td><td></td></tr><tr><td><strong>CircleCI</strong></td><td></td><td><a href="https://docs.currents.dev/getting-started/ci-setup/playwright-circleci">CircleCI</a></td><td data-object-fit="contain"><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-03dc8d0afc1f385a9045b74b702da8d4024568e0%2Fcircleci.png?alt=media">circleci.png</a></td><td data-object-fit="contain"><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-c3875d150bb58e226affc1deb7d80df1ea951714%2FCircleCI_idsGOJmkif_1.png?alt=media">CircleCI_idsGOJmkif_1.png</a></td></tr><tr><td><strong>Buildkite</strong></td><td></td><td><a href="https://docs.currents.dev/getting-started/ci-setup/buildkite">Buildkite</a></td><td data-object-fit="contain"><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-f8ba7433452ca944f75a4fc0450feb7410a71db5%2Fbuildkite.svg?alt=media">buildkite.svg</a></td><td></td></tr><tr><td><strong>Jenkins</strong></td><td></td><td><a href="https://docs.currents.dev/getting-started/ci-setup/jenkins">Jenkins</a></td><td data-object-fit="contain"><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-1ceb59cf8042e320103b6aef315947b312739d5b%2Fjenkins.svg?alt=media">jenkins.svg</a></td><td></td></tr><tr><td><strong>Azure DevOps</strong></td><td></td><td><a href="https://docs.currents.dev/getting-started/ci-setup/playwright-azure-devops">Azure DevOps</a></td><td data-object-fit="contain"><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-d22a802855276eff0da63d00d5abfa98e1b1ea2c%2Fazure-devops.svg?alt=media">azure-devops.svg</a></td><td></td></tr><tr><td><strong>AWS Code Build</strong></td><td></td><td><a href="https://docs.currents.dev/getting-started/ci-setup/playwright-aws-code-build">AWS Code Build</a></td><td data-object-fit="contain"><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-13d0111b847f83c8ec7c6c3655c240432dcebd46%2Faws.svg?alt=media">aws.svg</a></td><td></td></tr><tr><td><strong>Harness</strong></td><td></td><td><a href="https://docs.currents.dev/getting-started/ci-setup/playwright-harness">Harness</a></td><td data-object-fit="contain"><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-f014de27a18a44e9f789e0663599870720f71329%2Fharness.svg?alt=media">harness.svg</a></td><td data-object-fit="contain"><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-f014de27a18a44e9f789e0663599870720f71329%2Fharness.svg?alt=media">harness.svg</a></td></tr><tr><td><strong>NX</strong></td><td></td><td><a href="https://docs.currents.dev/getting-started/ci-setup/nx">NX</a></td><td data-object-fit="contain"><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-1397fd8e55a97386a9e5001b343609b2701f2928%2FNx-%23020617.png?alt=media">Nx-#020617.png</a></td><td data-object-fit="contain"><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-3aba7bc6513f076e8bae5d3e359ce1a6be21f1af%2FNx-%23FFF.png?alt=media">Nx-#FFF.png</a></td></tr></tbody></table>


# GitHub Actions

Running tests with Currents in GitHub Actions

Start with [Quick Start](https://docs.currents.dev/getting-started/ci-setup/github-actions/playwright-github-actions) for a workflow that records to Currents, then add what your setup needs from the articles below.

## Setup

* [Quick Start](https://docs.currents.dev/getting-started/ci-setup/github-actions/playwright-github-actions) - a workflow that records tests to Currents, and how to parallelize it.
* [Commit data for GitHub Actions](https://docs.currents.dev/getting-started/ci-setup/github-actions/commit-data-for-github-actions)  get the correct commit, branch and pull request on a run.
* [Custom Docker runners](https://docs.currents.dev/getting-started/ci-setup/github-actions/custom-docker-runners) - the environment variables to pass when the job runs in your own container.
* [Named Runners](https://docs.currents.dev/getting-started/ci-setup/github-actions/named-runners) - show which runner executed each spec file.

## Re-runs

* [Re-run Only Failed Tests](https://docs.currents.dev/getting-started/ci-setup/github-actions/re-run-failed-only-tests) - re-run only the tests that failed, for [sharded](https://docs.currents.dev/getting-started/ci-setup/github-actions/re-run-failed-only-tests/re-run-failed-only-tests-sharded) and [orchestrated](https://docs.currents.dev/getting-started/ci-setup/github-actions/re-run-failed-only-tests/re-run-failed-only-tests-orchestrated-v2) runs.
* [Custom CI Build ID for Re-runs](https://docs.currents.dev/getting-started/ci-setup/github-actions/re-run-failed-only-tests/custom-ci-build-id-for-reruns) - when your workflow sets its own CI build ID.

## Cancellation

* [Cancel Runs on Workflow Cancellation](https://docs.currents.dev/getting-started/ci-setup/github-actions/cancel-runs) - cancel the Currents run when the workflow is cancelled, so it does not sit in progress until the run timeout.

## Examples

The [currents-examples](https://github.com/currents-dev/currents-examples/tree/main/playwright/ci/github-actions) repository has complete workflows for sharding, orchestration, re-runs and visual testing.


# Quick Start

Running Playwright tests in Parallel in GitHub Actions using Matrix Workflow

{% hint style="info" %}
Check out the example repository [https://github.com/currents-dev/currents-examples](https://github.com/currents-dev/currents-examples/tree/main/playwright/ci/github-actions)
{% endhint %}

### Quick Start

The example workflow file below shows how to run Playwright tests in GitHub actions. It assumes the repository already reports to Currents locally, as set up in [Quick Start](https://docs.currents.dev/getting-started/your-first-playwright-run), so `npm ci` installs `@currents/playwright`.

Store the Record Key as the `CURRENTS_RECORD_KEY` repository secret and the Project ID as the `CURRENTS_PROJECT_ID` repository variable (**Settings → Secrets and variables → Actions**). Pull requests from forks get no secrets, so their runs don't reach Currents.

To record without storing the Record Key, give the job `permissions: id-token: write` and leave out `CURRENTS_RECORD_KEY`: `@currents/playwright` 2.8.0 or later exchanges the job's OIDC token for a short-lived record key. See [Record from CI with an OIDC token instead of a record key](https://docs.currents.dev/guides/record-key/record-from-ci-with-oidc). With `npx playwright test`, this needs Playwright 1.62 or later; on an older Playwright, run `npx pwc`.

<pre class="language-yaml"><code class="lang-yaml">name: Run Playwright Tests
on:
  pull_request:
    branches: [main]
jobs:
  run-tests:
    name: "Playwright Tests"
    timeout-minutes: 60
    runs-on: ubuntu-22.04
    container: <code class="expression">space.vars.PW_IMAGE_ROUTE + ":" + space.vars.LATEST_PW_IMAGE_VERSION</code>

    steps:
      - uses: actions/checkout@v4

      # https://github.com/actions/runner-images/issues/6775
      - run: |
          echo "$GITHUB_WORKSPACE"
          git config --global --add safe.directory "$GITHUB_WORKSPACE"

      - uses: actions/setup-node@v4
        with:
          node-version: "24.x"

      - name: Install dependencies
        run: npm ci

      - name: Playwright Tests
        continue-on-error: false
        env:
          CURRENTS_PROJECT_ID: ${{ vars.CURRENTS_PROJECT_ID }}
          CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
        run: npx playwright test
</code></pre>

The workflow above is the simplest way to get started. As the test suite grows, parallelization helps keep execution time fast.

### Parallelization

The [GitHub Actions matrix execution strategy](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix) can create multiple containers that run Playwright tests in parallel.

Each container receives a unique set of tests. This makes the browser test suite finish faster and gives feedback sooner.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FOt3a2yA71OFq87TCZ6cx%2FCI%20Runners.png?alt=media&amp;token=70fa657e-4304-4b0d-a77d-e984aa7af2b4" alt="Tests Parallelization with Github Actions"><figcaption><p>Tests Parallelization with Github Actions</p></figcaption></figure>

This can be done with [Playwright Sharding](https://playwright.dev/docs/test-sharding). Playwright can split tests between multiple CI machines using the `--shard` CLI flag. The examples below show how to set up sharding and orchestration.

{% hint style="info" %}
Looking for more ways to speed up CI? Read our [CI Optimization](https://docs.currents.dev/guides/ci-optimization) page.
{% endhint %}

### Examples

The [example repository](https://github.com/currents-dev/currents-examples/tree/main/playwright/ci/github-actions) showcases running Playwright tests in GitHub Actions. We've included several config files to exemplify the workflows:

* [test-basic-pwc.yml](https://github.com/currents-dev/currents-examples/blob/main/playwright/ci/github-actions/.github/workflows/test-basic-pwc.yml) - run Playwright tests in parallel using 3 shards of GitHub Actions Matrix and `pwc` command.
* [test-basic-reporter.yml](https://github.com/currents-dev/currents-examples/blob/main/playwright/ci/github-actions/.github/workflows/test-basic-reporter.yml) - run Playwright tests in parallel run using 3 shards of GitHub Actions Matrix and configuring Currents Reporter in `playwright.config.ts`.
* [test-or8n.yml](https://github.com/currents-dev/currents-examples/blob/main/playwright/ci/github-actions/.github/workflows/test-or8n.yml) - run Playwright tests in parallel Playwright using [Orchestration Setup](https://docs.currents.dev/guides/ci-optimization/playwright-orchestration) and GitHub Actions Matrix. Currents Orchestration speeds up CI runs by up to 40% (compared to native sharding) by optimally balancing tests between the available machines.
* [reruns-or8n.yml](https://github.com/currents-dev/currents-examples/blob/main/playwright/ci/github-actions/.github/workflows/reruns-or8n.yml) - Orchestration failed-only reruns.
* [argos-example.yml](https://github.com/currents-dev/currents-examples/blob/main/playwright/ci/github-actions/.github/workflows/argos-example.yml) - run Playwright tests in parallel using Currents Orchestration, use Argos CI for visual testing.


# Re-run Only Failed Tests

How to set up failed test re-runs on GitHub Actions

When a workflow fails in GitHub Actions, the failed jobs can be re-run. However, Playwright needs extra setup to re-run only the failed tests.

For GitHub Actions, Currents provides the [Last Failed GitHub Action](https://github.com/currents-dev/playwright-last-failed) to simplify re-runs with Playwright sharding or Currents Orchestration.

{% hint style="info" %}
The `playwright-last-failed` action uses `@currents/cmd` as a dependency. To control which version of `@currents/cmd` is used, install it as a dev dependency in `package.json` and use `npm ci` (or your package manager's equivalent frozen lockfile install) in GitHub Actions. Without this, the action installs `@currents/cmd` globally from npm, which may pull a different version than what's pinned in your lockfile.
{% endhint %}

Select the guide that matches your setup:

* [Sharded runs](https://docs.currents.dev/getting-started/ci-setup/github-actions/re-run-failed-only-tests/re-run-failed-only-tests-sharded) - fixed shard count and native Playwright `--shard` parallelism
* [Orchestrated runs](https://docs.currents.dev/getting-started/ci-setup/github-actions/re-run-failed-only-tests/re-run-failed-only-tests-orchestrated-v2) - `pwc-p discover` and `pwc-p run`
* [Custom CI Build ID for Re-runs](https://docs.currents.dev/getting-started/ci-setup/github-actions/re-run-failed-only-tests/custom-ci-build-id-for-reruns) - for sharded or orchestrated runs with a non-default CI build ID


# Sharded runs

How to set up failed test reruns for sharded Playwright runs on GitHub Actions

When using native Playwright `--shard` parallelism, the [Last Failed GitHub Action](https://github.com/currents-dev/playwright-last-failed) can fetch and rerun failed tests from the last workflow run.

Here's a guide:

<details>

<summary>Add the currents-dev/playwright-last-failed step</summary>

Add a step to the workflow before the test step runs.

<pre class="language-yaml"><code class="lang-yaml">- name: Playwright Last Failed action
<strong>  id: last-failed-action
</strong><strong>  uses: currents-dev/playwright-last-failed@v2
</strong>  with:
    pw-output-dir: basic/test-results
    matrix-index: ${{ matrix.shard }}
    matrix-total: ${{ strategy.job-total }}
</code></pre>

See the [action configuration for details](https://github.com/currents-dev/playwright-last-failed/blob/main/action.yml).

Without `key` or `CURRENTS_RECORD_KEY`, playwright-last-failed 2.2.0 or later uses the job's OIDC token instead, when the job has `permissions: id-token: write` and the project ID is set. See [Record from CI with an OIDC token instead of a record key](https://docs.currents.dev/guides/record-key/record-from-ci-with-oidc).

</details>

<details>

<summary>A full example</summary>

<pre class="language-yaml"><code class="lang-yaml">name: failed-only-reruns

on:
  push:

jobs:
  test-reporter:
    strategy:
      fail-fast: false
      matrix:
        shard: [1, 2, 3]
    timeout-minutes: 60
    runs-on: ubuntu-latest
    container: <code class="expression">space.vars.PW_IMAGE_ROUTE + ":" + space.vars.LATEST_PW_IMAGE_VERSION</code>
    env:
      CURRENTS_PROJECT_ID: ${{ vars.CURRENTS_PROJECT_ID }}
      CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
      CURRENTS_CI_BUILD_ID: ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.ref }}
      - run: |
          echo "$GITHUB_WORKSPACE"
          git config --global --add safe.directory "$GITHUB_WORKSPACE"
      - uses: actions/setup-node@v4
        with:
          node-version: "24.x"
      - name: Install dependencies
        run: |
          npm ci
          npx playwright install chrome
      - name: Playwright Last Failed action
        id: last-failed-action
        uses: currents-dev/playwright-last-failed@v2
        with:
          pw-output-dir: basic/test-results
          matrix-index: ${{ matrix.shard }}
          matrix-total: ${{ strategy.job-total }}
      - name: Playwright Tests
        working-directory: ./basic
        run: |
          COMMAND="npx playwright test --config playwright.config.reporter.ts ${{ steps.last-failed-action.outputs.extra-pw-flags }}"
          echo "Running command: $COMMAND"
          $COMMAND
</code></pre>

</details>

{% hint style="info" %}
For a workflow with a custom CI build ID, see [Custom CI Build ID for Re-runs](https://docs.currents.dev/getting-started/ci-setup/github-actions/re-run-failed-only-tests/custom-ci-build-id-for-reruns).
{% endhint %}

Full examples:

* [rerun-shards-pwc.yml](https://github.com/currents-dev/currents-examples/blob/main/playwright/ci/github-actions/.github/workflows/rerun-shards-pwc.yml) - re-run only the tests that failed in the previous run, using the `pwc` helper command from `@currents/playwright`.
* [rerun-shards-reporter.yml](https://github.com/currents-dev/currents-examples/blob/main/playwright/ci/github-actions/.github/workflows/rerun-shards-reporter.yml) - re-run only the tests that failed in the previous run, using reporter setup in `playwright.config.ts`.


# Orchestrated runs

How to set up failed test reruns for Orchestration on GitHub Actions

{% hint style="info" %}
Currents Orchestration assigns tests to all available CI runners, so **Re-run all jobs** should be used instead of re-running only failed jobs. Read more at [Orchestrated runs](https://docs.currents.dev/guides/ci-optimization/re-run-only-failed-tests/re-run-only-failed-tests-orchestrated-v2).
{% endhint %}

### Prerequisites

* [Orchestration Setup](https://docs.currents.dev/guides/ci-optimization/playwright-orchestration) — `@currents/playwright` on its latest version.
* `CURRENTS_RECORD_KEY`, `CURRENTS_PROJECT_ID`, and `CURRENTS_API_KEY` configured in GitHub Actions secrets
  * `CURRENTS_RECORD_KEY` can be left out when the job has `permissions: id-token: write`: `@currents/playwright` 2.8.0 or later gets a record key from the job's OIDC token. `CURRENTS_API_KEY` is still required. See [Record from CI with an OIDC token instead of a record key](https://docs.currents.dev/guides/record-key/record-from-ci-with-oidc).
* [playwright-last-failed@v2](https://github.com/currents-dev/playwright-last-failed) — exposes `extra-discovery-flags` for the discover step

### Step-by-step

#### Install `@currents/cmd`

The `playwright-last-failed` action depends on `@currents/cmd`. Pin it in the repository for reproducible installs:

```bash
npm i -D @currents/cmd
```

#### Set `CURRENTS_API_KEY`

Create an API key in the Currents Dashboard (see [Authentication](https://docs.currents.dev/api/get-started/authentication)) in addition to the Record Key. Add it as a [GitHub Actions secret](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions).

```yaml
env:
  CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
  CURRENTS_API_KEY: ${{ secrets.CURRENTS_API_KEY }}
```

#### Add the Playwright Last Failed step

```yaml
- name: Playwright Last Failed action
  id: last-failed-action
  uses: currents-dev/playwright-last-failed@v2
  with:
    or8n: true
    pw-output-dir: basic/test-results
```

When `or8n: true`, the action sets `extra-discovery-flags` for `pwc-p discover` (for example `--last-failed` on reruns).

#### Discover, then run

Run discovery once per job (or in a dedicated setup job that shares the test list artifact), then orchestrate with `pwc-p run`:

```yaml
- name: Discover tests to run
  working-directory: ./basic
  run: |
    npx pwc-p discover \
      --pwc-discovery-file tests.txt \
      ${{ steps.last-failed-action.outputs.extra-discovery-flags }}

- name: Playwright Tests
  working-directory: ./basic
  run: |
    npx pwc-p run \
      --pwc-discovery-file tests.txt
```

On the first run, `extra-discovery-flags` is empty and discovery records the full suite. On a workflow rerun, it includes `--last-failed` so only previously failed tests are orchestrated.

### Full example

{% code lineNumbers="true" %}

```yaml
name: failed-only-or8n-v2

on:
  push:

jobs:
  test-or8n:
    strategy:
      fail-fast: false
      matrix:
        shard: [1, 2, 3]
    timeout-minutes: 60
    runs-on: ubuntu-latest
    container: mcr.microsoft.com/playwright:v1.60.0-noble
    env:
      CURRENTS_PROJECT_ID: ${{ vars.CURRENTS_PROJECT_ID }}
      CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
      CURRENTS_CI_BUILD_ID: ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}
      CURRENTS_API_KEY: ${{ secrets.CURRENTS_API_KEY }}
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.ref }}
      - run: |
          echo "$GITHUB_WORKSPACE"
          git config --global --add safe.directory "$GITHUB_WORKSPACE"
      - uses: actions/setup-node@v4
        with:
          node-version: "24.x"
      - name: Install dependencies
        run: |
          npm ci
          npx playwright install chrome
      - name: Playwright Last Failed action
        id: last-failed-action
        uses: currents-dev/playwright-last-failed@v2
        with:
          or8n: true
          pw-output-dir: basic/test-results
      - name: Discover tests to run
        working-directory: ./basic
        run: |
          npx pwc-p discover \
            --pwc-discovery-file tests.txt \
            ${{ steps.last-failed-action.outputs.extra-discovery-flags }}
      - name: Playwright Tests
        working-directory: ./basic
        run: |
          npx pwc-p run --pwc-discovery-file tests.txt
```

{% endcode %}

{% hint style="info" %}
For a workflow with a custom CI build ID, see [Custom CI Build ID for Re-runs](https://docs.currents.dev/getting-started/ci-setup/github-actions/re-run-failed-only-tests/custom-ci-build-id-for-reruns).
{% endhint %}

The full workflow is included above. For V1, see [reruns-or8n.yml](https://github.com/currents-dev/currents-examples/blob/main/playwright/ci/github-actions/.github/workflows/reruns-or8n.yml).


# Custom CI Build ID for Re-runs

How to configure custom CI build IDs for failed test reruns on GitHub Actions

The [Last Failed GitHub Action](https://github.com/currents-dev/playwright-last-failed) uses the default CI build ID pattern to fetch the previous run information:

`${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}`

When you use a custom [CI Build ID](https://docs.currents.dev/guides/parallelization-guide/ci-build-id) for your test runs, set `previous-ci-build-id` to match that custom pattern.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FSwrur2Aq7UwtVc6Wziom%2Fcustom-ci-build-id.png?alt=media&amp;token=e917d202-eea2-46ec-bb7d-35d80292a2cb" alt=""><figcaption><p>Using custom CI build ID for reruns</p></figcaption></figure>

## For Sharded Runs (with matrix strategy)

Use the matrix index and total to ensure each shard reruns its own failed tests:

{% code overflow="wrap" %}

```yaml

# an example for custom value like:
# currents-${{ github.run_id }}-${{ github.run_attempt }}
- name: Compute previous run attempt
  id: previous-attempt
  run: echo "previous=$(( ${{ github.run_attempt }} - 1 ))" >> "$GITHUB_OUTPUT"
- name: Playwright Last Failed action
  uses: currents-dev/playwright-last-failed@v2
  with:
    # if a custom CI build id is used, set "previous-ci-build-id" accordingly
    previous-ci-build-id: currents-${{ github.run_id }}-${{ steps.previous-attempt.outputs.previous }}
    pw-output-dir: basic/test-results
    matrix-index: ${{ matrix.shard }}
    matrix-total: ${{ strategy.job-total }}
```

{% endcode %}

## For Orchestrated Runs (Currents assigns tests across machines)

Omit the matrix parameters and use `or8n: true` so Currents handles test distribution:

{% code overflow="wrap" %}

```yaml
- name: Compute previous run attempt
  id: previous-attempt
  run: echo "previous=$(( ${{ github.run_attempt }} - 1 ))" >> "$GITHUB_OUTPUT"
- name: Playwright Last Failed action
  uses: currents-dev/playwright-last-failed@v2
  with:
    or8n: true
    previous-ci-build-id: currents-${{ github.run_id }}-${{ steps.previous-attempt.outputs.previous }}
    pw-output-dir: basic/test-results
```

{% endcode %}


# Cancel Runs on Workflow Cancellation

Cancel the Currents run when a GitHub Actions workflow is cancelled

A cancelled workflow stops reporting mid-run. Currents has no way to tell that apart from a job that is still working, so the run stays in progress until it hits the project's [Run Timeouts](https://docs.currents.dev/dashboard/runs/run-timeouts). That leaves a run sitting in the feed as if it were live, for up to an hour.

Add a step that cancels the run when the job is cancelled:

```yaml
- name: Cancel the Currents run
  if: ${{ cancelled() }}
  run: npx --package @currents/cmd@2 currents run cancel
```

`if: cancelled()` runs the step only when the workflow was cancelled, so it costs nothing on a normal run. `npx --package @currents/cmd@2` runs the [`@currents/cmd`](https://docs.currents.dev/resources/reporters/currents-cmd) 2.x command without adding the package to the project. The command requires Node.js 20 or later.

## Which credential to use

[`currents run cancel`](https://docs.currents.dev/resources/reporters/currents-cmd/currents-cancel) authenticates with the [Record Key](https://docs.currents.dev/guides/record-key) the job already uses to report results, so no additional secret is needed. It identifies the run by its [CI Build ID](https://docs.currents.dev/guides/parallelization-guide/ci-build-id) or its run ID, which means the same step works on any CI provider.

{% hint style="warning" %}
Set `CURRENTS_CI_BUILD_ID` on the job, as the example below does. Without it Currents generates a CI Build ID that includes the test framework. The cancelling step cannot reconstruct that value from the environment, so it reports that there is no run to cancel.
{% endhint %}

The [cancel-run-gh-action](https://github.com/currents-dev/cancel-run-gh-action) does the same as a GitHub action and accepts either a record key or an [API Keys](https://docs.currents.dev/dashboard/administration/api-keys):

```yaml
- name: Cancel the Currents run
  if: ${{ cancelled() }}
  uses: currents-dev/cancel-run-gh-action@v1
```

With no inputs, the action reads `CURRENTS_RECORD_KEY`, `CURRENTS_PROJECT_ID` and `CURRENTS_CI_BUILD_ID` from the environment. Declare them on the job, the way the full example below does — a step's `env` is visible only to that step, so variables set on the reporting step reach the cancelling step empty.

Without a record key or API key, cancel-run-gh-action 1.2.0 or later (`@v1`) and `currents run cancel` from `@currents/cmd` 3.1.0 or later get a short-lived record key from the job's OIDC token when the job has `permissions: id-token: write`. See [Record from CI with an OIDC token instead of a record key](https://docs.currents.dev/guides/record-key/record-from-ci-with-oidc).

Like the command, the action can also identify the run by its run ID, through the `run-id` input or `CURRENTS_RUN_ID`. The [action's README](https://github.com/currents-dev/cancel-run-gh-action#inputs) lists every input.

## Full example

```yaml
name: Run Playwright Tests
on:
  pull_request:
    branches: [main]

# Cancel the previous run when a new commit is pushed to the same branch.
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  run-tests:
    runs-on: ubuntu-latest
    env:
      CURRENTS_PROJECT_ID: ${{ vars.CURRENTS_PROJECT_ID }}
      CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
      CURRENTS_CI_BUILD_ID: ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: "24.x"
      - run: npm ci

      - name: Playwright Tests
        run: npx playwright test

      - name: Cancel the Currents run
        if: ${{ cancelled() }}
        run: npx --package @currents/cmd@2 currents run cancel
```

`concurrency` with `cancel-in-progress: true` is what makes this worth setting up: every push to a branch cancels the workflow still running for the previous commit, and each of those leaves a run behind.

## Notes

* **Parallel jobs.** Every job of a parallelized run records into the same run, and every one of them can run the cancellation step. Cancelling a run that is already cancelled succeeds.
* **Nothing recorded yet.** A workflow cancelled before the first results reached Currents has no run to cancel. The step reports that and succeeds, so it does not add a failed step to an already cancelled workflow.
* **Hard cancellations.** A job killed without running its remaining steps never reaches the step. That covers a cancelled job that does not honour `if: cancelled()`, and a runner that disappears. Those runs still end at the inactivity timeout.

See [Cancelling Runs](https://docs.currents.dev/dashboard/runs/cancel-run) for what cancelling a run affects: test statuses, plan usage, analytics and integrations.


# Commit data for GitHub Actions

How to get correct git commit information when using GitHub Actions

### GitHub Pull Request Title, Issue Link and Branch Name

{% hint style="info" %}
**Update Jan 30, 2024**

`@currents/playwright@0.12.0` and `cypress-cloud@1.10.0` automatically detect Pull Request information when running in GitHub Actions.
{% endhint %}

The recent (Jan 30, 2024) releases of `@currents/playwright@0.12.0` and `cypress-cloud@1.10.0` handles git information better when running in GitHub Actions triggered by `` `pull_request` `` trigger.

* PR title becomes Run Title (instead of a generic message PR #XX)
* Effective Branch becomes the PR HEAD branch name - allowing more meaningful usage in analytics and notification filters
* UI displays a direct link to GitHub Pull Request issue

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FXccp1KAtQsvKZ1GUA5AW%2Fcurrents-2024-01-30-14.57.07%402x.png?alt=media&amp;token=a2ef75e7-ac46-4cab-9f70-16f3bf82fb70" alt=""><figcaption><p>Capturing GitHub PR data</p></figcaption></figure>

### Merge commit in pull request runs

{% hint style="info" %}
`@currents/playwright@2.5.1` and `@currents/cmd@1.11.0` record the last commit of the pull request when GitHub Actions checks out a merge commit.
{% endhint %}

On [`pull_request`](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request) events, `actions/checkout` checks out a merge commit that GitHub creates by merging the pull request into the base branch. Its message looks like this:

```
Merge de7282540ac30ee4e32a0b1fede4f6391b4cc321 into fa58941d8a807b83ec5a3e5bfb83418ce12173c7
```

The reporter detects the merge commit and records the last commit of the pull request instead: its SHA, message, author and timestamp.

With the default `actions/checkout` settings, the clone has only the merge commit, so the reporter fetches the pull request commit:

```
git fetch --depth=1 --no-tags origin <pull request commit SHA>
```

The fetch uses the credentials that `actions/checkout` stores in the clone, and times out after 3 seconds. If it fails, the run shows the merge commit's message and author, as with earlier versions. For example, the fetch fails in a private repository checked out with `persist-credentials: false`. The commit SHA and branch still come from the pull request, so PR comments and commit statuses are not affected.

To turn the fetch off, set `CURRENTS_DISABLE_HEAD_COMMIT_FETCH=true`. See [Commit Information](https://docs.currents.dev/dashboard/runs/commit-information) for other CI providers.

#### Earlier versions and Cypress

With `cypress-cloud` and earlier versions of the reporters, runs show the merge commit's message and author. To record the last commit of the pull request, check out that commit:

```yaml
- uses: actions/checkout@v4
  with:
    ref: ${{ github.event.pull_request.head.sha }}
```

The workflow then tests the last commit of the pull request, not the result of merging it into the base branch. It does not catch conflicts or failures that appear only after the merge.


# Custom Docker runners

Self hosted/managed docker runners

Github Actions gives you the option to use your custom docker containers to execute your tests instead of directly using their built-in runners.

This usually leads to the loss of git information, and environment variables not being available. So, in this case, for Currents to be able to gather all the information needed, you need to setup the needed environment variables accordingly.

The best way to access this variables is through the context objects, specifically in this case the `github` one.

```
GITHUB_WORKFLOW=${{github.workflow}}
GITHUB_ACTION=true
GITHUB_EVENT_NAME=${{github.event_name}}
GITHUB_RUN_ID=${{github.run_id}}
GITHUB_RUN_ATTEMPT=${{github.run_attempt}}
GITHUB_REPOSITORY=${{github.repository}}

COMMIT_INFO_BRANCH=${{github.ref_name}}
COMMIT_INFO_MESSAGE=${{github.event.head_commit.message}}
COMMIT_INFO_EMAIL=${{github.event.head_commit.author.email}}
COMMIT_INFO_AUTHOR=${{github.event.head_commit.author.name}}
COMMIT_INFO_SHA=${{github.sha}}
COMMIT_INFO_TIMESTAMP=${{github.event.head_commit.timestamp}}
COMMIT_INFO_REMOTE=${{github.repository}}
```

Adding these environment variables to your `.yml` file will allow your custom docker runner to report the correct information to Currents and have all the available information in the dashboard to use it as a usual Github Action tests execution.


# Named Runners

Github Actions provides the ability to use human-readable runner names, and Currents displays these in the dashboard, allowing you to see which runner executed each spec file.

The typical method for creating a matrix strategy for runners in Github Actions is as follows:

```yaml
matrix:
    shard: [1/3, 2/3, 3/3]
```

However, there are several ways to achieve this, such as naming the machines with human-readable names like this:

```yaml
matrix:
    include:
        - runner_name: "Runner 1"
	    shard: 1/2
	- runner_name: "Runner 2"
      	    shard: 2/2
```

This creates jobs that looks like this in Github Actions:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FiTAh4JhcIfg1KD8Mmxz1%2Fimage.png?alt=media&amp;token=40629705-4313-4b5d-9a08-5f812c6f3479" alt="" width="310"><figcaption><p>Named Runners</p></figcaption></figure>

The final step is to visualize this in the Currents dashboard, which can be done by passing the runner name into the CURRENTS\_MACHINE\_ID environment variable:

```yaml
- name: Run Playwright tests
    env:
        CURRENTS_MACHINE_ID: ${{ matrix.runner_name }}
    run: npx pwc --key ${{secrets.CURRENTS_RECORD_KEY}} --project-id ${{secrets.CURRENTS_PROJECT_ID}} --ci-build-id ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt}} --shard ${{ matrix.shard }}
```

The `machineId` will now be visible in the Currents dashboard for each spec file, making it possible to identify which machine or job executed a specific spec file.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FrKmz2izqlgddxKYX1iFg%2Fimage.png?alt=media&amp;token=d5cb7aba-9d4a-4758-b217-28225c415ac1" alt="" width="326"><figcaption><p>Spec file details view</p></figcaption></figure>

Here is a complete example of a Github Action yaml file with this setup:

<details>

<summary><code>workflow.yaml</code></summary>

```yaml
name: Playwright Tests
on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]
jobs:
  playwright-tests:
    timeout-minutes: 60
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        include:
          - runner_name: "Runner 1"
            shard: 1/2
          - runner_name: "Runner 2"
            shard: 2/2
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: "24.x"

      - name: Install Playwright browsers
        run: npx playwright install --with-deps

      - name: Install dependencies
        run: npm install

      - name: Run Playwright tests
        env:
          CURRENTS_MACHINE_ID: ${{ matrix.runner_name }}
        run: npx pwc --key ${{secrets.CURRENTS_RECORD_KEY}} --project-id ${{secrets.CURRENTS_PROJECT_ID}} --ci-build-id ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt}} --shard ${{ matrix.shard }}
```

</details>

It is also possible to add a dynamic number of named runners by including an extra job in the workflow:

```yaml
generate-matrix:
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
    steps:
      - name: Set number of shards
        id: set-shards
        run: echo "SHARDS=5" >> $GITHUB_ENV

      - name: Generate matrix
        id: set-matrix
        run: |
          SHARDS=${SHARDS:-2}  # Default to 2 if not set
          MATRIX="{\"include\":["
          for i in $(seq 1 $SHARDS); do
            if [ $i -gt 1 ]; then MATRIX="$MATRIX,"; fi
            MATRIX="$MATRIX{\"runner_name\":\"MyRunner $i\",\"shard\":\"$i/$SHARDS\"}"
          done
          MATRIX="$MATRIX]}"
          echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
```

You only need to update `run: echo "SHARDS=5" >> $GITHUB_ENV` to the `SHARDS` number you actually want.

A complete example can be found here:

<details>

<summary><code>dynamic-runners-workflow.yaml</code></summary>

```yaml
name: Playwright Tests
on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]
jobs:
  generate-matrix:
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
    steps:
      - name: Set number of shards
        id: set-shards
        run: echo "SHARDS=5" >> $GITHUB_ENV

      - name: Generate matrix
        id: set-matrix
        run: |
          SHARDS=${SHARDS:-2}  # Default to 2 if not set
          MATRIX="{\"include\":["
          for i in $(seq 1 $SHARDS); do
            if [ $i -gt 1 ]; then MATRIX="$MATRIX,"; fi
            MATRIX="$MATRIX{\"runner_name\":\"MyRunner $i\",\"shard\":\"$i/$SHARDS\"}"
          done
          MATRIX="$MATRIX]}"
          echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"

  playwright-tests:
    needs: generate-matrix 
    timeout-minutes: 60
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
    steps:
      - name: Log matrix
        run: |
          echo "Running on ${{ matrix.runner_name }} with shard ${{ matrix.shard }}"
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: "24.x"

      - name: Install Playwright browsers
        run: npx playwright install --with-deps

      - name: Install dependencies
        run: npm install

      - name: Run Playwright tests
        env:
          CURRENTS_MACHINE_ID: ${{ matrix.runner_name }}
        run: npx pwc --key ${{secrets.CURRENTS_RECORD_KEY}} --project-id ${{secrets.CURRENTS_PROJECT_ID}} --ci-build-id ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt}} --shard ${{ matrix.shard }}
```

</details>


# GitLab


# Quick Start

Running Playwright test in parallel using GitLab CI/CD

{% hint style="info" %}
TL;DR take a look at the example repository:

<https://gitlab.com/currents.dev/gitlab-playwright-currents>
{% endhint %}

The example [`.gitlab-ci.yml`](https://gitlab.com/currents.dev/gitlab-playwright-currents/-/blob/main/.gitlab-ci.yml) file creates a GitLab CI pipeline with 3 workers using 3 [Playwright Shards](https://playwright.dev/docs/test-sharding):

<pre class="language-yaml"><code class="lang-yaml"># .gitlab-ci.yml
default:
  image: <code class="expression">space.vars.PW_IMAGE_ROUTE + ":" + space.vars.LATEST_PW_IMAGE_VERSION</code>

stages:
  - test

test:
  image: <code class="expression">space.vars.PW_IMAGE_ROUTE + ":" + space.vars.LATEST_PW_IMAGE_VERSION</code>
  stage: test
  parallel: 3

  script:
    - npm ci
    - npx playwright install
    - cd ./basic
    - npx pwc --key $CURRENTS_RECORD_KEY --project-id bnsqNa --shard=$CI_NODE_INDEX/$CI_NODE_TOTAL
</code></pre>

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fyktlmn6KuwTbiJUIOtBc%2Fcurrents-2023-11-04-02.04.23%402x.png?alt=media&amp;token=d5c2f042-cc2d-43cf-9345-cc733b85b8a4" alt=""><figcaption><p>Running 3 parallel jobs Playwright jobs in GitLab CI</p></figcaption></figure>

### Setup <a href="#user-content-setup" id="user-content-setup"></a>

* Create an account at <https://app.currents.dev> and grab the **Project ID** and **Record Key**.
* Add `CURRENTS_RECORD_KEY` as [GitLab CI/CD Secrets](https://docs.gitlab.com/ee/ci/variables/) (make sure it's not protected)

On GitLab.com, the job can use its OIDC token instead of a stored Record Key, with `@currents/playwright` 2.8.0 or later. See [Record from CI with an OIDC token instead of a record key](https://docs.currents.dev/guides/record-key/record-from-ci-with-oidc).

Additional resources:

* Playwright Features on Currents: <https://currents.dev/playwright>
* Integration Documentation: <https://currents.dev/readme/integration-with-playwright/currents-playwright>
* CI Build ID Guide: <https://currents.dev/readme/guides/cypress-ci-build-id>

### GitLab CI Playwright Results <a href="#user-content-gitlab-ci-playwright-results" id="user-content-gitlab-ci-playwright-results"></a>

The results are being reported to Currents for more efficient troubleshooting, and monitoring test suite flakiness and performance.

Currents will collect the following information:

* console output
* screenshots
* videos
* trace files
* timing
* outcomes
* flaky tests
* error details
* tags for more convenient management of the tests

#### GitLab Merge Request Notes <a href="#user-content-gitlab-merge-request-notes" id="user-content-gitlab-merge-request-notes"></a>

Take a look at the example merge request: <https://gitlab.com/currents.dev/gitlab-playwright-currents/-/merge_requests/3>

When [GitLab integration](https://currents.dev/readme/integrations/gitlab) is enabled, Currents will post a Merge Commit note with run results:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FRBXrvHJyWbMmihPXN6E0%2Fcurrents-gitlab-merge-note.png?alt=media&amp;token=1ba76197-f907-4af6-aa1b-be4da49a3bb8" alt=""><figcaption><p>Currents Merge Request Notes</p></figcaption></figure>

In addition, Currents will post an [External Status check](https://docs.gitlab.com/ee/user/project/merge_requests/status_checks.html) for every Playwright project configured. For example:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FSXCbGXETG6Mbtwui0pDt%2Fcurrents-gitlab-status-check.png?alt=media&amp;token=ab4e9ffa-199f-4f04-b400-5d3d120d44d9" alt=""><figcaption><p>Example of GitLab CI External Status Check</p></figcaption></figure>


# Re-run Only Failed Tests

How to setup failed tests re-run on GitLab

When a workflow fails in GitLab CI/CD you have the option to re-run the failed jobs. However, an additional setup is required for properly configuring Playwright for rerunning only the failed tests. See [Re-run Only Failed Tests](https://docs.currents.dev/guides/re-run-only-failed-tests) guide for details.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FwuaTeaUtaIevNusJljzh%2Fcurrents-2024-10-02-14.07.49%402x.png?alt=media&amp;token=65047381-3f11-4778-addd-f8db3a635603" alt=""><figcaption><p>Rerunning only the failed jobs on GitLab CI/CD</p></figcaption></figure>

#### Playwright Sharding

If you're using [Playwright Sharding](https://docs.currents.dev/guides/parallelization-guide/pw-parallelization/playwright-sharding) for running your tests in parallel, use [currents cache](https://docs.currents.dev/resources/reporters/currents-cmd/currents-cache) command to store the last run results and simplify re-run workflows.

`currents cache` from `@currents/cmd` 3.1.0 or later can use the job's OIDC token instead of a stored record key. See [Record from CI with an OIDC token instead of a record key](https://docs.currents.dev/guides/record-key/record-from-ci-with-oidc).

Example workflows are available in our GitLab repositories:

* [reruns-pwc.yml](https://gitlab.com/currents.dev/gitlab-playwright-currents/-/blob/main/.gitlab/ci/with-reruns-pwc.yml?ref_type=heads) - re-run only failed tests on GitLab CI using 3 parallel runners and Playwright Shards + Currents `pwc` command
* [reruns-reporter.yml](https://gitlab.com/currents.dev/gitlab-playwright-currents/-/blob/main/.gitlab/ci/with-reruns-reporter.yml?ref_type=heads) - re-run only failed tests on GitLab CI using 3 parallel runners and Playwright Shards + Currents reporter in `playwright.config.ts`

**Install the @currents/cmd package**

```bash
npm i -D @currents/cmd
```

**Add an after\_script to upload the cache**

Add an `after_script` to the end of your job that uploads run information to the cache

```yaml
after_script:
    # Save the last-run.json to cache after the run
    - npx currents cache set --pw-output-dir basic/test-results --preset last-run
```

See the [`currents cache` options](https://docs.currents.dev/resources/reporters/currents-cmd/currents-cache) for the flags.

**Add a download cache step to your script**

Update your job script to download the cache prior to running tests

```yaml
script:
    - npm ci
    # Grab the last run from cache. CacheId is automatically calculated for GitLab, and a .currents_env file is created with extra env variables
    # $EXTRA_PW_FLAGS will contain the correct --shard flag, as well as --last-failed if this was a retried job
    # $RUN_ATTEMPT will be populated with a value 1+ based on how many times this job has been retried
    - npx currents cache get --preset last-run --continue
    - cat .currents_env >> $GITLAB_ENV && source .currents_env
    - npx playwright install
    # Run playwright, provide a build id with the run-attempt included and also pass $EXTRA_PW_FLAGS 
    - export CURRENTS_CI_BUILD_ID="reporter-$CI_PIPELINE_ID-$RUN_ATTEMPT"
    - npx playwright test -c playwright.config.reporter.ts $EXTRA_PW_FLAGS

```

See the [`currents cache` options](https://docs.currents.dev/resources/reporters/currents-cmd/currents-cache) for the flags.

**Full example**

<pre class="language-yaml"><code class="lang-yaml">test-rerun-reporter:
  image: <code class="expression">space.vars.PW_IMAGE_ROUTE + ":" + space.vars.LATEST_PW_IMAGE_VERSION</code>
  stage: test
  parallel: 3
  variables:
    CURRENTS_PROJECT_ID: ${{ vars.CURRENTS_PROJECT_ID }}
    # CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
  script:
    - npm ci
    # Grab the last run from cache. CacheId is automatically calculated for GitLab, and a .currents_env file is created with extra env variables
    # $EXTRA_PW_FLAGS will contain the correct --shard flag, as well as --last-failed if this was a retried job
    # $RUN_ATTEMPT will be populated with a value 1+ based on how many times this job has been retried
    - npx currents cache get --preset last-run --continue
    - cat .currents_env >> $GITLAB_ENV &#x26;&#x26; source .currents_env
    - npx playwright install
    - cd ./basic
    # Run playwright, provide a build id with the run-attempt included and also pass $EXTRA_PW_FLAGS 
    - export CURRENTS_CI_BUILD_ID="reporter-$CI_PIPELINE_ID-$RUN_ATTEMPT"
    - npx playwright test -c playwright.config.reporter.ts $EXTRA_PW_FLAGS
  after_script:
    # Save the last-run.json to cache after the run
    - npx currents cache set --pw-output-dir basic/test-results --preset last-run
</code></pre>

#### Currents Orchestration

In case you're using Currents Orchestration for running Playwright tests in parallel, use [currents run get](https://docs.currents.dev/resources/reporters/currents-cmd/currents-run-get) to fetch the results of the last run from the [API](https://docs.currents.dev/api/).

* [Orchestration Setup](https://docs.currents.dev/guides/ci-optimization/playwright-orchestration)
* [Orchestration (v1)](https://docs.currents.dev/guides/ci-optimization/playwright-orchestration/playwright-orchestration-v1)

\
An example workflow is available in our GitLab demo repository

* [rerun-or8n.yml](https://gitlab.com/currents.dev/gitlab-playwright-currents/-/blob/main/.gitlab/ci/with-reruns-pwcp.yml?ref_type=heads) - rerun only failed tests on GitLab CI/CD with Currents Orchestration

**Install the @currents/cmd package**

```bash
npm i -D @currents/cmd
```

**Set `CURRENTS_API_KEY` environment variable**

Obtain an API key (see [Authentication](https://docs.currents.dev/api/get-started/authentication)) and [Record Key](https://docs.currents.dev/guides/record-key) from Currents Dashboard and set [GitLab CI/CD variable](https://docs.gitlab.com/ee/ci/variables/) accordingly

```yaml
variables:
    CURRENTS_PROJECT_ID: ${{ vars.CURRENTS_PROJECT_ID }}
    CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
    CURRENTS_API_KEY: ${{ secrets.CURRENTS_API_KEY }}
```

**Add an after\_script to upload the cache**

Add an `after_script` to the end of your job that uploads GitLab retry information to the cache

```yaml
after_script:
    # Save the last-run.json to cache after the run
    - npx currents cache set --pw-output-dir basic/test-results --preset last-run
```

See [currents cache](https://docs.currents.dev/resources/reporters/currents-cmd/currents-cache) documentation for all the available options

**Add an API get-run step to your script**

Update your job script to download the cache prior to running tests, and then also grab the previous run.

{% code overflow="wrap" %}

```yaml
script:
    - npm ci
    # Grab the last run from cache. CacheId is automatically calculated for GitLab, and a .currents_env file is created with extra env variables
    # $EXTRA_PWCP_FLAGS will contain --last-failed if this was a retried job (pass to discover, not run)
    # $RUN_ATTEMPT will be populated with a value 1+ based on how many times this job has been retried
    - npx currents cache get --preset last-run --continue
    - cat .currents_env >> $GITLAB_ENV && source .currents_env
    # Grab the complete last run from the API so orchestration can find all the failures
    - npx currents run get --branch=$CI_COMMIT_REF_NAME --pw-last-run --output=basic/test-results/.last-run.json || true
    - npx playwright install
    # Discover tests to run; $EXTRA_PWCP_FLAGS includes --last-failed on retried jobs
    - npx pwc-p discover --pwc-discovery-file tests.txt $EXTRA_PWCP_FLAGS
    # Run pwc-p with the discovery file and a build id that includes the run attempt
    - npx pwc-p run --ci-build-id=or8n-$CI_PIPELINE_ID-$RUN_ATTEMPT --pwc-discovery-file tests.txt

```

{% endcode %}

See [currents run get](https://docs.currents.dev/resources/reporters/currents-cmd/currents-run-get) for all the options

**Full example**

<pre class="language-yaml"><code class="lang-yaml">test-rerun-pwcp:
  image: <code class="expression">space.vars.PW_IMAGE_ROUTE + ":" + space.vars.LATEST_PW_IMAGE_VERSION</code>
  stage: test
  parallel: 3
  variables:
    CURRENTS_PROJECT_ID: ${{ vars.CURRENTS_PROJECT_ID }}
    # CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
    # CURRENTS_API_KEY: ${{ secrets.CURRENTS_API_KEY }}
  script:
    - npm ci
    # Grab the last run from cache. CacheId is automatically calculated for GitLab, and a .currents_env file is created with extra env variables
    # $EXTRA_PWCP_FLAGS will contain --last-failed if this was a retried job (pass to discover, not run)
    # $RUN_ATTEMPT will be populated with a value 1+ based on how many times this job has been retried
    - npx currents cache get --preset last-run --continue
    - cat .currents_env >> $GITLAB_ENV &#x26;&#x26; source .currents_env
    # Grab the complete last run from the API so orchestration can find all the failures
    - npx currents run get --branch=$CI_COMMIT_REF_NAME --pw-last-run --output=basic/test-results/.last-run.json || true
    - npx playwright install
    # Discover tests to run; $EXTRA_PWCP_FLAGS includes --last-failed on retried jobs
    - npx pwc-p discover --pwc-discovery-file tests.txt $EXTRA_PWCP_FLAGS
    # Run pwc-p with the discovery file and a build id that includes the run attempt
    - npx pwc-p run --ci-build-id=or8n-$CI_PIPELINE_ID-$RUN_ATTEMPT --pwc-discovery-file tests.txt
  after_script:
    # Save the last-run to cache in order to track the run attempts
    - npx currents cache set --preset last-run --pw-output-dir basic/test-results
</code></pre>


# Custom Docker runners

Self hosted/managed docker runners

Gitlab CI/CD gives you the option to use your custom docker containers to execute your tests instead of directly using their built-in runners.

This usually leads to the loss of git information and environment variables not be directly available, so in this case for Currents to be able to gather all the information needed you need to setup the needed environment variables accordingly.

```
GITLAB_CI=true
CI_PIPELINE_ID=$CI_PIPELINE_ID
CI_PIPELINE_URL=$CI_PIPELINE_URL
CI_BUILD_ID=$CI_BUILD_ID
CI_JOB_ID=$CI_JOB_ID
CI_JOB_URL=$CI_JOB_URL
CI_JOB_NAME=$CI_JOB_NAME
GITLAB_HOST=$GITLAB_HOST
CI_PROJECT_ID=$CI_PROJECT_ID
CI_PROJECT_URL=$CI_PROJECT_URL
CI_REPOSITORY_URL=$CI_REPOSITORY_URL
CI_ENVIRONMENT_URL=$CI_ENVIRONMENT_URL
CI_DEFAULT_BRANCH=$CI_DEFAULT_BRANCH

COMMIT_INFO_BRANCH=$CI_COMMIT_BRANCH
COMMIT_INFO_MESSAGE=$CI_COMMIT_MESSAGE
COMMIT_INFO_SHA=$CI_COMMIT_SHA
COMMIT_INFO_REMOTE=$CI_REPOSITORY_URL
```

Adding these environment variables to your `.yml` file will allow your custom docker runner to report the correct information to Currents and have all the available information in the dashboard to use it as a usual Gitlab CI/CD tests execution.

## Fallback: Using CURRENTS\_CI\_URL

If your GitLab environment variables are not forwarded to the Docker container and auto-detection fails, you can explicitly provide the CI URL using the `CURRENTS_CI_URL` environment variable:

```
CURRENTS_CI_URL=$CI_JOB_URL
```

Or for GitLab pipelines:

```
CURRENTS_CI_URL=$CI_PIPELINE_URL
```

This ensures the run link in the Currents Dashboard points back to the correct GitLab job or pipeline. See [Configuration](https://docs.currents.dev/resources/reporters/currents-playwright/configuration) for more details on `CURRENTS_CI_URL`.


# Jenkins

Running Playwright tests in parallel with Jenkins and Currents Dashboard

Here's an example of Jenkins pipeline that is running Playwright tests in parallel on 2 workers.

The pipeline will be running 2 workers, based on <code class="expression">space.vars.PW\_IMAGE\_ROUTE + ":" + space.vars.LATEST\_PW\_IMAGE\_VERSION</code> Docker image. Those workers will run all the tests in parallel.

The steps are:

* Use <code class="expression">space.vars.PW\_IMAGE\_ROUTE + ":" + space.vars.LATEST\_PW\_IMAGE\_VERSION</code> as the base image
* Install the necessary dependencies: `playwright` and `@currents/playwright`
* Populate the environment variable `CURRENTS_RECORD_KEY` using [Jenkins Credentials Store](https://jenkins.io/doc/book/using/using-credentials/). Learn more about [Record Key](https://docs.currents.dev/guides/record-key)
* Populate the environment variable `CURRENTS_PROJECT_ID` using [Jenkins Credentials Store](https://jenkins.io/doc/book/using/using-credentials/).
* Run Playwright tests on 2 workers, using CI Build ID for "connecting" the workers to the same parallel run. See [CI Build ID](https://docs.currents.dev/guides/parallelization-guide/ci-build-id).

{% code overflow="wrap" %}

```
npx pwc --key "$CURRENTS_RECORD_KEY" --project-id "$CURRENTS_PROJECT_ID" --ci-build-id "$BRANCH_NAME-$BUILD_ID"
```

{% endcode %}

Here's the full Jenkins pipeline configuration file:

<pre class="language-groovy"><code class="lang-groovy">pipeline {
  agent {
    // this image provides everything needed to run Playwright
    docker {
      image '<code class="expression">space.vars.PW_IMAGE_ROUTE + ":" + space.vars.LATEST_PW_IMAGE_VERSION</code>'
    }
  }

  stages {
    // installs node dependencies
    stage('build') {
      steps {
        echo "Running build ${env.BUILD_ID} on ${env.JENKINS_URL}"
        sh 'npm install playwright @currents/playwright'
      }
    }

    // this stage runs Playwright tests, and each agent uses the workspace
    // from the previous stage
    stage('Playwright parallel tests') {
      environment {
        // see https://jenkins.io/doc/book/using/using-credentials/
        CURRENTS_RECORD_KEY = credentials('currents-record-key')
        CURRENTS_PROJECT_ID = credentials('currents-project-id')
      }

      // Run parallel workers, see:
      // https://jenkins.io/doc/book/pipeline/syntax/#parallel
      parallel {
        // each worker is running the same command, 
        stage('tester A') {
          steps {
            echo "Running build ${env.BUILD_ID}"
            sh "npx pwc --key ${env.CURRENTS_RECORD_KEY} --project-id ${env.CURRENTS_PROJECT_ID} --ci-build-id ${env.BRANCH_NAME}-${env.BUILD_ID} --shard 1/2 --output test-results/shard-1"
          }
        }

        // second tester runs the same command
        stage('tester B') {
          steps {
            echo "Running build ${env.BUILD_ID}"
            sh "npx pwc --key ${env.CURRENTS_RECORD_KEY} --project-id ${env.CURRENTS_PROJECT_ID} --ci-build-id ${env.BRANCH_NAME}-${env.BUILD_ID} --shard 2/2 --output test-results/shard-2"
          }
        }
      }

    }
  }
}
</code></pre>

## Using `--last-failed` with shards and orchestration

We have made available a [public repository with an example](https://github.com/currents-dev/currents-examples/tree/main/playwright/ci/jenkins/jenkins-last-failed) of how to setup last failed functionality using shards and orchestration in different machines.

Here you will be able to find the following Jenkins file that accepts two parameters:

* A CI Build ID from a previous run that you can use to apply the `--last-failed` flag. If this parameter is set, then the pipeline will automatically apply this tag and only run the failed tests from that run, if found.
* A checkbox for confirming if you want to run an orchestrated run. If so, the pipeline will use `pwc-p` command instead of `pwc`.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FYg19hOsYIvxo6JyFtaUN%2Fimage.png?alt=media&amp;token=c1d4bbed-8ecf-4121-8c3a-9483b5a30bda" alt="" width="375"><figcaption><p>Pipeline Params</p></figcaption></figure>

In order to use the `--last-failed` flag, in addition to the project ID and record key, a Currents API key is needed (You can find it in the API Keys section in your dashboard).

{% hint style="info" %}
This example uses the API Key and the [`currents run get`](https://docs.currents.dev/resources/reporters/currents-cmd/currents-run-get) command of `@currents/cmd` package to query for the run corresponding to the CI Build ID and generates the `.last-run.json` file with that information.
{% endhint %}

Also, within the Jenkinsfile you can set different values as env variables for the total amount of shards `TOTAL_SHARDS` or the number of parallel jobs for orchestration `PARALLEL_JOBS.`

<details>

<summary>Install the @currents/cmd package</summary>

```bash
npm install -D @currents/cmd
```

</details>

<details>

<summary><code>Jenkinsfile</code></summary>

```groovy
pipeline {
    agent any
    parameters {
        string(name: 'CI_BUILD_ID', defaultValue: 'none', description: 'Set this value if you want to execute only the failed tests from a specific run')
        booleanParam(name: 'IS_ORCHESTRATION', defaultValue: false, description: 'Set this value if you want to execute an orchestrated run')
    }
    environment {
        CURRENTS_PROJECT_ID = credentials('CURRENTS_PROJECT_ID')
        CURRENTS_RECORD_KEY = credentials('CURRENTS_RECORD_KEY')
        CURRENTS_CI_BUILD_ID = "reporter-${JOB_NAME}-${BUILD_ID}-${BUILD_NUMBER}"
        CURRENTS_API_KEY = credentials('CURRENTS_API_KEY')
        TOTAL_SHARDS = 3
        PARALLEL_JOBS = 4
    }
    options {
        timeout(time: 60, unit: 'MINUTES')
    }
    stages {
        stage('Checkout') {
            steps {
                checkout scm
            }
        }

        stage('Install Dependencies') {
            steps {
                sh 'npm ci'
                sh 'npx playwright install'
                sh 'rm -rf test-results'
                sh 'rm -rf .last-run.json'
            }
        }

        stage('Set params CI Build ID') {
            steps {
                script {
                    env.CI_BUILD_ID = "${params.CI_BUILD_ID}"
                    echo "CI_BUILD_ID is set to: ${params.CI_BUILD_ID}"
                }
                echo "Verify values: ${env.CI_BUILD_ID} ${params.IS_ORCHESTRATION}"
            }
        }

        stage('Run Tests decision') {
            steps {
                runTestsDecision(env.CI_BUILD_ID, params.IS_ORCHESTRATION)
            }
        }
    }
}

def runTestsDecision(ciBuildId, isOrchestration) {
    if (ciBuildId && ciBuildId != 'none') {
        stage('Run Tests with last failed') {
            script {
                echo "Running tests with last failed: ${ciBuildId} ${env.TOTAL_SHARDS}"
                script {
                    sh "npx currents run get --api-key ${env.CURRENTS_API_KEY} --project-id ${env.CURRENTS_PROJECT_ID} --ci-build-id ${env.CI_BUILD_ID} --pw-last-run --output .last-run.json"
                    sh 'cat .last-run.json'
                }
                if (isOrchestration && isOrchestration == true) {
                    runPlaywrightOrchestration(env.PARALLEL_JOBS.toInteger(), true)
                } else {
                    runPlaywrightSharded(env.TOTAL_SHARDS.toInteger(), true)
                }
            }
        }
    } else {
        stage('Run Tests') {
            script {
                echo 'Running tests'
                if (isOrchestration && isOrchestration == true) {
                    runPlaywrightOrchestration(env.PARALLEL_JOBS.toInteger(), false)
                } else {
                    runPlaywrightSharded(env.TOTAL_SHARDS.toInteger(), false)
                }
            }
        }
    }
}

def runPlaywrightSharded(shardTotal, lastFailed) {
    def parallelStages = [:]
    for (int i = 1; i <= shardTotal; i++) {
        def shardIndex = i
        parallelStages["shard${shardIndex}"] = {
            if (lastFailed) {
                sh "mkdir -p test-results/shard-${shardIndex}"
                sh "cp .last-run.json test-results/shard-${shardIndex}/.last-run.json"
                runPlaywrightTestsLastFailed(shardIndex, shardTotal)
            } else {
                runPlaywrightTests(shardIndex, shardTotal)
            }
        }
    }
    parallel parallelStages
}

def runPlaywrightTests(shardIndex, shardTotal) {
    stage("Run Playwright Tests - Shard ${shardIndex}") {
        script {
            def command = "npx pwc --shard=${shardIndex}/${shardTotal}"
            echo "Running command: ${command}"
            sh "${command}"
        }
    }
}

def runPlaywrightTestsLastFailed(shardIndex, shardTotal) {
    stage("Run Playwright Tests - Shard ${shardIndex}") {
        script {
            def command = "npx pwc --shard=${shardIndex}/${shardTotal} --last-failed --output test-results/shard-${shardIndex}"
            echo "Running command: ${command}"
            sh "${command}"
        }
    }
}

def runPlaywrightOrchestration(parallelTotal, lastFailed) {
    def parallelStages = [:]
    for (int i = 1; i <= parallelTotal; i++) {
        def parallelIndex = i
        parallelStages["parallel${parallelIndex}"] = {
            if (lastFailed) {
                sh "mkdir -p test-results/parallel-${parallelIndex}"
                sh "cp .last-run.json test-results/parallel-${parallelIndex}/.last-run.json"
                runPlaywrightTestsLastFailedOrchestration(parallelIndex)
            } else {
                runPlaywrightTestsOrchestration(parallelIndex)
            }
        }
    }
    parallel parallelStages
}

def runPlaywrightTestsOrchestration(parallelIndex) {
    stage("Run Playwright Tests - Orchestration ${parallelIndex}") {
        script {
            def command = 'npx pwc-p run'
            echo "Running command: ${command}"
            sh "${command}"
        }
    }
}

def runPlaywrightTestsLastFailedOrchestration(parallelIndex) {
    stage("Run Playwright Tests - Orchestration ${parallelIndex}") {
        script {
            def discoveryFile = "test-results/parallel-${parallelIndex}/tests.txt"
            def discoverCommand = "npx pwc-p discover --pwc-discovery-file ${discoveryFile} --last-failed --output test-results/parallel-${parallelIndex}"
            def runCommand = "npx pwc-p run --pwc-discovery-file ${discoveryFile}"
            echo "Running command: ${discoverCommand}"
            sh "${discoverCommand}"
            echo "Running command: ${runCommand}"
            sh "${runCommand}"
        }
    }
}

```

</details>


# 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](https://docs.currents.dev/guides/record-key) and `CURRENTS_PROJECT_ID`
* Store `CURRENTS_RECORD_KEY`: <https://circleci.com/docs/guides/security/contexts/>

The job can use a CircleCI OIDC token instead of a stored Record Key, with `@currents/playwright` 2.8.0 or later. See [Record from CI with an OIDC token instead of a record key](https://docs.currents.dev/guides/record-key/record-from-ci-with-oidc).

The config below assumes the repository already reports to Currents locally, as set up in [Quick Start](https://docs.currents.dev/getting-started/your-first-playwright-run), 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.


# Buildkite

Running Playwright tests in parallel on Buildkite with Currents

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

* <https://github.com/currents-dev/currents-examples/tree/main/playwright/ci/buildkite>
* <https://buildkite.com/andrew-goldis/currents-buildkite>
  {% endhint %}

Run Playwright tests in parallel on [Buildkite](https://buildkite.com) using the native [Playwright Sharding](https://playwright.dev/docs/test-sharding) to split tests between multiple containers. Parallelizing tests helps decrease overall run duration.

Currents collects results from distributed parallel Buildkite builds for efficient troubleshooting. Each container receives a unique set of tests to run, providing faster feedback from your test suite.

## Setup

* Create an organization at <https://app.currents.dev>
* Create a new project
* Obtain `CURRENTS_RECORD_KEY` [Record Key](https://docs.currents.dev/guides/record-key) and `CURRENTS_PROJECT_ID`
* Store `CURRENTS_RECORD_KEY` as a pipeline-level secret in your Buildkite dashboard or via the [Buildkite Secrets plugin](https://buildkite.com/docs/pipelines/security/secrets/managing)

The step can use a Buildkite OIDC token instead of a stored Record Key, with `@currents/playwright` 2.8.0 or later. See [Record from CI with an OIDC token instead of a record key](https://docs.currents.dev/guides/record-key/record-from-ci-with-oidc). With `npx playwright test`, this needs Playwright 1.62 or later; on an older Playwright, run `npx pwc`.

## Sharding

Buildkite provides `BUILDKITE_PARALLEL_JOB` (0-indexed) and `BUILDKITE_PARALLEL_JOB_COUNT` environment variables for parallel jobs. Since Playwright shards are 1-indexed, compute the shard index as `BUILDKITE_PARALLEL_JOB + 1`:

{% code overflow="wrap" %}

```bash
npx playwright test --shard=$((BUILDKITE_PARALLEL_JOB + 1))/$BUILDKITE_PARALLEL_JOB_COUNT
```

{% endcode %}

## Configuration

Configure the Currents reporter in your `playwright.config.ts`:

{% code title="playwright.config.ts" overflow="wrap" %}

```typescript
import { currentsReporter } from "@currents/playwright";
import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
  reporter: [currentsReporter()],
  // ... other config
});
```

{% endcode %}

Create a `currents.config.ts` file:

{% code title="currents.config.ts" %}

```typescript
import { CurrentsConfig } from "@currents/playwright";

const currentsConfig: CurrentsConfig = {
  projectId: process.env.CURRENTS_PROJECT_ID ?? "your-project-id",
  recordKey: process.env.CURRENTS_RECORD_KEY ?? "",
};

export default currentsConfig;
```

{% endcode %}

## Example Pipeline

<pre class="language-yaml"><code class="lang-yaml">steps:
  - label: ":playwright: Playwright Tests"
    command: |
      npm ci
      npx playwright install --with-deps
      npx playwright test --shard=$((BUILDKITE_PARALLEL_JOB + 1))/$BUILDKITE_PARALLEL_JOB_COUNT
    parallelism: 3
    plugins:
      - docker#v5.11.0:
          image: "<code class="expression">space.vars.PW_IMAGE_ROUTE + ":" + space.vars.LATEST_PW_IMAGE_VERSION</code>"
    env:
      CURRENTS_PROJECT_ID: "bnsqNa"
      CURRENTS_RECORD_KEY: "${CURRENTS_RECORD_KEY}"
</code></pre>

This pipeline:

* Runs 3 parallel containers using Buildkite's `parallelism` feature
* Uses the official Microsoft Playwright Docker image
* Splits tests using Playwright's native sharding with Buildkite environment variables
* Reports results to Currents via the Playwright Reporter

## Environment Variables

| Variable                       | Description                                           |
| ------------------------------ | ----------------------------------------------------- |
| `CURRENTS_PROJECT_ID`          | Your Currents project ID                              |
| `CURRENTS_RECORD_KEY`          | Your Currents record key (store as secret)            |
| `BUILDKITE_PARALLEL_JOB`       | Current job index (0-indexed, provided by Buildkite)  |
| `BUILDKITE_PARALLEL_JOB_COUNT` | Total number of parallel jobs (provided by Buildkite) |

{% hint style="info" %}
Looking for more ways to speed up CI? Read our [CI Optimization](https://docs.currents.dev/guides/ci-optimization) guide.
{% endhint %}


# Azure DevOps

Running Playwright test in parallel on Azure DevOps and Currents Dashboard

{% 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/azure-devops)
{% endhint %}

Currents can use the native [Playwright Sharding](https://playwright.dev/docs/test-sharding) to split the tests between multiple containers. The results from distributed runs will be collected together with the generated artifacts to provide insights into test suite performance.

The [example repository](https://github.com/currents-dev/currents-examples/tree/main/playwright/ci/azure-devops) uses 3 Azure DevOps containers to allow parallel execution of the test showcasing Currents as a reporting service.

* Connect a new/existing Azure Pipeline to a repository containing your Playwright tests.
* Create an organization, get your **Record Key** and **Project Id** at [https://app.currents.dev](https://app.currents.dev/)
* Create or modify an existing [Variable Group](https://learn.microsoft.com/en-us/azure/devops/pipelines/library/variable-groups?view=azure-devops\&tabs=yaml), and add a new secret variable called `CURRENTS_RECORD_KEY` with your **Record Key**.
* Include your **Project Id** in an env variable called `CURRENTS_PROJECT_ID` in your pipeline configuration.
* Ensure the [@current/playwright](https://docs.currents.dev/resources/reporters/currents-playwright) package has been integrated into your tests.
* Modify your `azure-pipelines.yml` file to run the tests and use one of the [example pipeline files](https://github.com/currents-dev/currents-examples/blob/main/playwright/ci/azure-devops/azure-pipelines.yml) as a reference.

Here's an example pipeline file:

<pre class="language-yaml"><code class="lang-yaml">trigger:
- main

jobs:
- job: pwcTests
  displayName: Playwright Tests - pwc
  strategy:
    matrix:
      chromium-1:
        project: chromium
        shard: 1/3
      chromium-2:
        project: chromium
        shard: 2/3
      chromium-3:
        project: chromium
        shard: 3/3
  pool:
    vmImage: ubuntu-latest

  # If you choose to not use the playwright container, you will also need to npx install playwright in your steps
  container: <code class="expression">space.vars.PW_IMAGE_ROUTE + ":" + space.vars.LATEST_PW_IMAGE_VERSION</code>
  variables:
  - name: npm_config_cache
    value: $(Pipeline.Workspace)/.npm

  # You can use a variable group to store the CURRENTS_RECORD_KEY secret
  - group: currents-settings
  steps:
  - task: NodeTool@0
    displayName: 'Install NodeJS'
    inputs:
      versionSpec: '24'

  # Speed up the execution by caching the dependencies
  # https://docs.microsoft.com/en-us/azure/devops/pipelines/caching/?view=azure-devops
  - task: Cache@2
    inputs:
      key: 'npm | "$(Agent.OS)" | package-lock.json'
      restoreKeys: |
         npm | "$(Agent.OS)"
      path: $(npm_config_cache)
    displayName: Cache npm

  # Install Node dependencies
  - script: npm ci
    displayName: 'Install Dependencies'

  # Use pwc as the currents wrapper for playwright test
  # Replace the CURRENTS_PROJECT_ID value with your own from https://app.currents.dev
  - script: npx pwc --shard=$(shard)
    workingDirectory: '$(build.sourcesdirectory)/basic'
    displayName: 'Run Basic Tests'
    env:
      CI: 'true'
      CURRENTS_PROJECT_ID: '3W3DU4'
      CURRENTS_RECORD_KEY: $(CURRENTS_RECORD_KEY)
</code></pre>

Pipeline executions will be recorded and available in the Currents Dashboard, and test results and artifacts will be automatically uploaded.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FvGwkjdtLBSdPa9T7o9kc%2Fpw-azure-run-console.png?alt=media&amp;token=d7779983-115f-43c2-bc83-47831524e1b8" alt=""><figcaption><p>Running Playwright Tests in Azure DevOps Pipeline</p></figcaption></figure>

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fy1uX4r2SZaCn4bIzQFaQ%2Fpw-azure-pipeline.png?alt=media&amp;token=0233eda7-905a-4ba3-b567-7b25e5302616" alt=""><figcaption><p>Running Playwright Tests in Azure DevOps Pipeline</p></figcaption></figure>


# AWS Code Build

Running Playwright Tests in Parallel on AWS CodeBuild 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/aws-codebuild)
{% endhint %}

Executing Playwright tests in parallel on AWS CodeBuild can significantly reduce the overall run duration. AWS CodeBuild supports [Batched Build](https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build.html) in [matrix mode](https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build.html#batch_build_matrix) for launching several workers in parallel.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FiMM5uiOPJgpo3sXgLk20%2Fcurrents-2023-11-15-13.23.30%402x.png?alt=media&amp;token=cddd728b-1e10-4d5a-817c-8a43043303f9" alt=""><figcaption><p>Use AWS CodeBulld Matrix mode to run Playwright tests in parallel with Currents. 1 batch job (1) triggering 3 parallel build jobs (2).</p></figcaption></figure>

### Prerequisites

To enable parallel runs, please make sure that you have privileged access to your AWS Account and that you can create/modify an AWS CodeBuild Project.

### Configuration

#### Obtain Currents Credentials <a href="#user-content-obtain-currents-credentials" id="user-content-obtain-currents-credentials"></a>

Create an organization, and get [Record Key](https://docs.currents.dev/guides/record-key) and **Project ID** at [https://app.currents.dev](https://app.currents.dev/).

#### Create `buildspec.yml`

Create a `buildspec.yml` file in the root directory of your application's source code repository. This file defines the build and test steps for your application.

Set the **Project ID** for `pwc` command, for example:

<pre data-overflow="wrap"><code>npx pwc --project-id <a data-footnote-ref href="#user-content-fn-1">&#x3C;project_id></a> --key $CURRENTS_RECORD_KEY --ci-build-id $CODEBUILD_INITIATOR --shard $WORKER/3
</code></pre>

{% hint style="info" %}
The example uses `pwc` CLI command to run the tests. You can use `npx playwright test` command and configure `@currents/playwright` as a reporter. Please refer to the [documentation](https://currents.dev/readme/integration-with-playwright/currents-playwright#currents-playwright-reporter).
{% endhint %}

The `buildspec.yml` file uses [matrix mode](https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build) to start 3 containers for running the test in parallel. Each container will have the environment variable `WORKER` set to `1,2,3` correspondingly, we use it to configure [Playwright Sharding](https://playwright.dev/docs/test-parallel#shard-tests-between-multiple-machines) `--shard $WORKER/3`

```yaml
## buildspec.yml
version: 0.2

batch:
  fast-fail: false
  build-matrix:
    dynamic:
      buildspec:
        - buildspec.yml
      env:
        variables:
          WORKER:
            - 1
            - 2
            - 3

phases:
  install:
    runtime-versions:
      nodejs: 24
    commands:
      # install playwright and its dependencies
      - npm ci
      - npx playwright install
      - npx playwright install-deps

  build:
    commands:
      # Optionally, set COMMIT_INFO variables to override the default values. See https://currents.dev/readme/runs/run-details#playwright-cypress-git-information
      # - export COMMIT_INFO_BRANCH="$(git rev-parse HEAD | xargs git name-rev |
      #   cut -d' ' -f2 | sed 's/remotes\/origin\///g')"
      # - export COMMIT_INFO_MESSAGE="$(git log -1 --pretty=%B)"
      # - export COMMIT_INFO_EMAIL="$(git log -1 --pretty=%ae)"
      # - export COMMIT_INFO_AUTHOR="$(git log -1 --pretty=%an)"
      # - export COMMIT_INFO_SHA="$(git log -1 --pretty=%H)"
      # - export COMMIT_INFO_REMOTE="$(git config --get remote.origin.url)"

      # update shard details according to the overall # of containers
      - npx pwc --project-id <project_id> --key $CURRENTS_RECORD_KEY --ci-build-id $CODEBUILD_INITIATOR --shard $WORKER/3
```

**Configure `CURRENTS_RECORD_KEY`**

Save the [Record Key](https://docs.currents.dev/guides/record-key) as `CURRENTS_RECORD_KEY` [Environment variable](https://docs.aws.amazon.com/codebuild/latest/userguide/change-project-console.html#change-project-console-environment). It is strongly recommended to use your **Record Key** in a secure secrets storage. Please refer to the [detailed guide](https://www.learnaws.org/2022/11/18/aws-codebuild-secrets-manager/), here is an overview of the steps:

* Create a new entry in AWS Secrets Manager with the **Record Key**. Please note that the generated secret is a JSON document, you should note the `json_key` of the actual record key value and use it later.
* Get the secret ARN
* Update the Build Project environment variables as follows:
  * Variable name: `CURRENTS_RECORD_KEY`
  * Variable value: the ARN of previously created secret + json\_key, for example: `<secret-arn>:<json-key>`
* Update the IAM execution role to allow reading of previously created secret

#### Configure AWS Project

Configure AWS-specific project settings like IAM execution policy, resources class and so on. Please refer to [AWS CodeBuild documentation](https://docs.aws.amazon.com/codebuild/) for details to explore possible configuration settings.

**Configure Source Batch Mode**

* Set the **Project Setting > Edit Source**
* Configure the repository details, the events that should trigger new builds
* Configure **Primary source webhook events > Build Type** to **Batch build** to start 3 parallel workers in [matrix mode](https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build)

### Example: Triggering Parallel Playwright AWS CodeBuild

This [example repository](https://github.com/currents-dev/currents-examples/tree/main/playwright/ci/aws-codebuild) showcases running Playwright tests on AWS CodeBuild in parallel while using [Currents](https://currents.dev/) as the reporting dashboard. It has an example [AWS CodeBuilld Project configuration](https://github.com/currents-dev/currents-examples/blob/main/playwright/ci/aws-codebuild/aws-project-config-output.json).

{% embed url="<https://player.mux.com/My3U014yc3mr6CzXNad701cZdvT900Nz2ooVlMR6aqoBmE?min-resolution=1080p>" %}
Example of triggering an AWS CodeBuild Playwright Tests via a commit
{% endembed %}

[^1]: replace with real project id


# Harness

Running Playwright tests on Harness CI with Currents reporting and parallel sharding

This guide explains how to run Playwright tests on [Harness Continuous Integration](https://developer.harness.io/docs/continuous-integration/) and report results to [Currents](https://currents.dev). It follows Harness NextGen pipeline patterns ([Run steps](https://developer.harness.io/docs/continuous-integration/use-ci/run-step-settings), [stage parallelism](https://developer.harness.io/docs/continuous-integration/use-ci/run-tests/speed-up-ci-test-pipelines-using-parallelism), [secrets](https://developer.harness.io/docs/platform/secrets/add-use-text-secrets)).

{% hint style="warning" %}
**`CURRENTS_CI_BUILD_ID` is mandatory** for Harness. Harness is **not** in Currents’ [auto-detected CI providers](https://docs.currents.dev/guides/parallelization-guide/ci-build-id#build-id-for-popular-ci-providers). If you omit it, Currents may generate a **different** build ID per job or shard: parallel Playwright shards **will not merge into one run**, reporting and orchestration **breaks**, and **retries** can collide with or duplicate prior runs. Always set `CURRENTS_CI_BUILD_ID` in every Run step (see below).
{% endhint %}

## Prerequisites

**Currents**

* Organization and project at <https://app.currents.dev>
* **Project ID** and **Record Key** - see [Record Key](https://docs.currents.dev/guides/record-key)
* **`CURRENTS_CI_BUILD_ID`** set in CI for every Playwright step (mandatory on Harness - see [CI Build ID](#ci-build-id-mandatory-on-harness))
* `@currents/playwright` installed and configured - see [@currents/playwright](https://docs.currents.dev/resources/reporters/currents-playwright)

**Harness**

* A **CI pipeline** with a **Build** (`CI`) stage
* A [Docker registry connector](https://developer.harness.io/docs/platform/connectors/cloud-providers/ref-cloud-providers/docker-registry-connector-settings-reference/) that can pull your Playwright image (for example `mcr.microsoft.com/playwright`). Replace `YOUR_DOCKER_CONNECTOR` in the examples with your connector reference (for example `account.harnessImageRegistry` or your org’s Docker Hub connector).

## Store the Record Key as a Harness secret

1. In Harness, create an **encrypted text** secret at the appropriate [scope](https://developer.harness.io/docs/platform/role-based-access-control/rbac-in-harness/#permissions-hierarchy-scopes) (project, org, or account).
2. Use a stable **identifier** (Harness derives it from the name). Example identifier: `currents_record_key`.
3. Reference it only by **identifier** in expressions, not the display name. See [Add and reference text secrets](https://developer.harness.io/docs/platform/secrets/add-use-text-secrets).

{% hint style="warning" %}
Avoid `$` in secret values when possible; the shell may expand it. If unavoidable, follow Harness guidance (for example quoting or base64 encoding) in the [text secrets](https://developer.harness.io/docs/platform/secrets/add-use-text-secrets) documentation.
{% endhint %}

## Application configuration

Use the same Playwright + Currents setup as other CI providers.

**`playwright.config.ts`** (reporter):

{% code title="playwright.config.ts" overflow="wrap" %}

```typescript
import { currentsReporter } from "@currents/playwright";
import { defineConfig } from "@playwright/test";

export default defineConfig({
  reporter: [currentsReporter()],
  use: {
    trace: "retain-on-failure-and-retries",
    video: "retain-on-failure",
    screenshot: "on",
  },
  // ...projects, testDir, etc.
});
```

{% endcode %}

**`currents.config.ts`**:

{% code title="currents.config.ts" %}

```typescript
import { CurrentsConfig } from "@currents/playwright";

const config: CurrentsConfig = {
  projectId: process.env.CURRENTS_PROJECT_ID ?? "",
  recordKey: process.env.CURRENTS_RECORD_KEY ?? "",
};

export default config;
```

{% endcode %}

## CI Build ID (mandatory on Harness)

**You must provide `CURRENTS_CI_BUILD_ID`** (environment variable or reporter config). It is a **required** input for correct Currents behavior on Harness - not optional.

Without a stable, explicit value:

* Each parallel shard may get its own ID → **multiple runs** instead of one combined run
* Reruns may reuse or collide with IDs → **stale or rejected** uploads - see the [CI Build ID FAQ](https://docs.currents.dev/guides/parallelization-guide/ci-build-id#examples)

The value must be:

* **Unique per pipeline execution** (each execution gets its own Currents run)
* **Identical across all parallel Playwright shards** in the same execution (shards merge into one run)
* **Different when you retry the same logical build**, when you need a fresh run - see [CI Build ID](https://docs.currents.dev/guides/parallelization-guide/ci-build-id)

Harness resolves expressions before the step runs. Common choices:

| Approach             | Expression (example)                                                                         | Notes                                                                                                                                                             |
| -------------------- | -------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Execution only       | `<+pipeline.executionId>`                                                                    | Unique per execution; confirm behavior for **re-runs** in your Harness edition                                                                                    |
| Execution + sequence | Concatenate `<+pipeline.executionId>` with `<+pipeline.sequenceId>` using `+` or `.concat()` | See [Harness variables](https://developer.harness.io/docs/platform/variables-and-expressions/harness-variables); helps separate retries when `sequenceId` changes |

Compose multi-part IDs with the concatenation patterns documented under **Harness variables** (for example combining `<+pipeline.identifier>`, `<+pipeline.executionId>`, and `<+pipeline.sequenceId>`).

## Option A - Single Run step (no parallelism)

Add a **Run** step in your **CI** stage. Set **Container Registry** to your Docker connector and **Image** to a [Playwright image](https://playwright.dev/docs/docker) tag that matches your `@playwright/test` version.

<pre class="language-yaml"><code class="lang-yaml">execution:
  steps:
    - step:
        type: Run
        name: playwright_currents
        identifier: playwright_currents
        spec:
          connectorRef: YOUR_DOCKER_CONNECTOR
          image: <code class="expression">space.vars.PW_IMAGE_ROUTE + ":" + space.vars.LATEST_PW_IMAGE_VERSION</code>
          shell: Bash
          command: |-
            npm ci
            npx playwright install chrome
            npx playwright test
          envVariables:
            CI: "true"
            CURRENTS_PROJECT_ID: YOUR_CURRENTS_PROJECT_ID
            CURRENTS_RECORD_KEY: &#x3C;+secrets.getValue("currents_record_key")>
            CURRENTS_CI_BUILD_ID: &#x3C;+pipeline.executionId>
</code></pre>

* Replace `YOUR_CURRENTS_PROJECT_ID` with your project ID, or use a [pipeline variable](https://developer.harness.io/docs/platform/variables-and-expressions/harness-variables) (for example `<+pipeline.variables.currents_project_id>`).
* Replace `currents_record_key` with your secret’s **identifier**.

## Option B - Parallel Playwright sharding (recommended)

Use **stage-level** [parallelism](https://developer.harness.io/docs/continuous-integration/use-ci/run-tests/speed-up-ci-test-pipelines-using-parallelism) so Harness runs multiple copies of the stage. Playwright’s [`--shard`](https://playwright.dev/docs/test-sharding) is **1-based**; Harness parallel indices are **0-based**, so use `HARNESS_NODE_INDEX + 1` for the shard index.

Do **not** rely on Harness `split_tests` for Playwright unless you intentionally drive a custom split; native sharding matches the rest of Currents’ CI docs and keeps setup simple.

<pre class="language-yaml"><code class="lang-yaml">- stage:
    name: playwright_tests
    identifier: playwright_tests
    type: CI
    strategy:
      parallelism: 3
      maxConcurrency: 3
    spec:
      cloneCodebase: true
      platform:
        os: Linux
        arch: Amd64
      runtime:
        type: Cloud
        spec: {}
      execution:
        steps:
          - step:
              type: Run
              name: playwright_currents_shard
              identifier: playwright_currents_shard
              spec:
                connectorRef: YOUR_DOCKER_CONNECTOR
                image: <code class="expression">space.vars.PW_IMAGE_ROUTE + ":" + space.vars.LATEST_PW_IMAGE_VERSION</code>
                shell: Bash
                command: |-
                  npm ci
                  npx playwright install chrome
                  SHARD_INDEX=$((HARNESS_NODE_INDEX + 1))
                  npx playwright test --shard=${SHARD_INDEX}/${HARNESS_NODE_TOTAL}
                envVariables:
                  CI: "true"
                  HARNESS_NODE_INDEX: &#x3C;+strategy.iteration>
                  HARNESS_NODE_TOTAL: &#x3C;+strategy.iterations>
                  CURRENTS_PROJECT_ID: YOUR_CURRENTS_PROJECT_ID
                  CURRENTS_RECORD_KEY: &#x3C;+secrets.getValue("currents_record_key")>
                  CURRENTS_CI_BUILD_ID: &#x3C;+pipeline.executionId>
</code></pre>

* Tune `parallelism` and `maxConcurrency` per [best practices for looping strategies](https://developer.harness.io/docs/platform/pipelines/looping-strategies/best-practices-for-looping-strategies).
* **`CURRENTS_CI_BUILD_ID` is mandatory** - the **same** value must reach every shard (the `<+pipeline.executionId>` expression above resolves identically for all parallel instances of the same execution).

## Environment variables reference

| Variable               | Required            | Description                                                                                                                                                                                            |
| ---------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `CURRENTS_PROJECT_ID`  | Yes                 | Currents project ID from the dashboard                                                                                                                                                                 |
| `CURRENTS_RECORD_KEY`  | Yes                 | Record key; inject via `<+secrets.getValue("SECRET_IDENTIFIER")>` (or org/account-scoped variant)                                                                                                      |
| `CURRENTS_CI_BUILD_ID` | **Yes (mandatory)** | **Required on Harness.** Stable ID shared by all shards in one execution; must change appropriately on retries - see [CI Build ID](https://docs.currents.dev/guides/parallelization-guide/ci-build-id) |
| `CI`                   | Optional            | Set to `true` so tools behave as in CI                                                                                                                                                                 |
| `HARNESS_NODE_INDEX`   | Parallel only       | `<+strategy.iteration>` - 0-based shard index                                                                                                                                                          |
| `HARNESS_NODE_TOTAL`   | Parallel only       | `<+strategy.iterations>` - must match `parallelism`                                                                                                                                                    |

## Optional - Pipeline or stage variables

You can define **pipeline** or **stage** variables for non-secret settings (for example project ID) and reference them with expressions such as `<+pipeline.variables.currents_project_id>`. Precedence for environment variables in Harness is **step > stage > pipeline**. See [Variables](https://developer.harness.io/docs/open-source/pipelines/variables) (open-source YAML) and [Harness variables](https://developer.harness.io/docs/platform/variables-and-expressions/harness-variables) (expressions).

## Harness Open Source / GitOps pipeline YAML

If you use the **open-source pipeline** schema (`kind: pipeline`), environment variables are often declared under `spec.options.envs` (pipeline-wide) or `spec.envs` on a `ci` stage, and Run steps use `spec.container` and `spec.script`. The **Currents** requirements are the same: include **`CURRENTS_CI_BUILD_ID` (mandatory)**, other `CURRENTS_*` variables, and `npx playwright test` with optional `--shard`. Map them to your schema per [CI stage reference](https://developer.harness.io/docs/open-source/reference/pipelines/yaml/stage.type.ci).

## Further reading

* [Harness CI Run step settings](https://developer.harness.io/docs/continuous-integration/use-ci/run-step-settings)
* [Speed up CI with parallelism](https://developer.harness.io/docs/continuous-integration/use-ci/run-tests/speed-up-ci-test-pipelines-using-parallelism)
* Currents: [CI Optimization](https://docs.currents.dev/guides/ci-optimization), [Orchestration Setup](https://docs.currents.dev/guides/ci-optimization/playwright-orchestration)

{% hint style="info" %}
Got stuck configuring CI? Reach out to [Support](https://docs.currents.dev/resources/support).
{% endhint %}


# NX

Running Playwright tests with NX

## Running Playwright tests in an Nx project with Currents

[Nx](https://github.com/nrwl/nx) is a build system with monorepo support and powerful integrations. Playwright tests executions in Nx can be done by using [@nx/playwright](https://nx.dev/nx-api/playwright) plugin.

[This example repository](https://github.com/currents-dev/currents-examples/tree/main/playwright/ci/nx) showcases all the implementation described here.

To use the nx playwright plugin, Currents client must be set as reporter option in the `playwright.config` file.

Here a quick example:

```typescript
import { nxE2EPreset } from '@nx/playwright/preset';
import { defineConfig, devices } from '@playwright/test';
import { CurrentsConfig, currentsReporter } from '@currents/playwright';

const currentsConfig: CurrentsConfig = {
  recordKey: process.env.CURRENTS_RECORD_KEY,
  projectId: process.env.CURRENTS_PROJECT_ID,
};

const nxConf = nxE2EPreset(__filename);
export default defineConfig({
  ...nxConf,
  reporter: [currentsReporter(currentsConfig)],
  ...
  ...
});
```

{% hint style="info" %}
See a more scalable [example for multiple projects here](https://github.com/currents-dev/currents-examples/tree/main/playwright/ci/nx)
{% endhint %}

In order to execute the tests, our example `project.json` file includes the `e2e` target and Playwright plugin as `executor` property.

```json
{
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
  "name": "e2e-02",
  "projectType": "application",
  "sourceRoot": "apps/e2e-02/src",
  "targets": {
    "e2e": {
      "executor": "@nx/playwright:playwright",
      "options": {
        "skipInstall": true,
        "output": "{workspaceRoot}/playwright-report/{projectName}",
        "config": "{projectRoot}/playwright.config.ts"
      }
    }
  }
}
```

The command to execute the tests with Playwright is:

```bash
CURRENTS_RECORD_KEY=recordkey \
CURRENTS_PROJECT_ID=projectid \
CURRENTS_CI_BUILD_ID=`date +%s` \
nx run-many -t e2e  --parallel=2 --verbose
```

This will create a run execution in Currents reporting the tests results.

### Using `--last-failed` flag

For executing only the failed tests according to a previous run, add the `--last-failed` flag to the execution command.

```bash
CURRENTS_RECORD_KEY=recordkey \
CURRENTS_PROJECT_ID=projectid \
CURRENTS_CI_BUILD_ID=`date +%s` \
nx run-many -t e2e  --parallel=2 --verbose --last-failed
```

{% hint style="info" %}
For a more detailed explanation on last failed CI setup, [see here](https://docs.currents.dev/guides/ci-optimization/re-run-only-failed-tests)
{% endhint %}

### Orchestration in a single project

It is possible to orchestrate the Playwright tests in a single nx project by using the same `ci-build-id` across multiple machines.

This is showcased in the `e2e-03` nx project and the `project.json` file is slightly different than for the other projects.

```json
{
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
  "name": "e2e-03",
  "projectType": "application",
  "sourceRoot": "apps/e2e-03/src",
  "targets": {
    "or8n-discover": {
      "executor": "nx:run-commands",
      "options": {
        "cwd": "apps/e2e-03",
        "commands": [
          {
            "command": "npx pwc-p discover --pwc-discovery-file tests.txt"
          }
        ]
      }
    },
    "or8n": {
      "executor": "nx:run-commands",
      "options": {
        "cwd": "apps/e2e-03",
        "commands": [
          {
            "command": "npx pwc-p run"
          }
        ]
      }
    }
  }
}
```

Key differences with other nx projects in the example repository:

* `executor` property has the value `nx:run-commands`.
* A `command` property is added within `options`. This executes `npx pwc-p run` for orchestration. See [Orchestration Setup](https://docs.currents.dev/guides/ci-optimization/playwright-orchestration).
* Reporter config in `playwright.config` file is not needed
* Orchestration runs the full suite by default - use `or8n-discover` first to filter tests

To locally execute orchestration nx project:

```bash
CURRENTS_RECORD_KEY=recordkey \
CURRENTS_PROJECT_ID=projectid \
CURRENTS_CI_BUILD_ID=unique-id \
nx run-many -t or8n
```

Or with discovery (for filtered runs):

```bash
CURRENTS_RECORD_KEY=recordkey \
CURRENTS_PROJECT_ID=projectid \
CURRENTS_CI_BUILD_ID=unique-id \
nx run-many -t or8n-discover -- --grep @smoke && nx run-many -t or8n -- --pwc-discovery-file tests.txt
```

```yaml
name: Run or8n Tests

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main
  workflow_dispatch:

jobs:
  e2e_tests:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        shard: [1, 2, 3]

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Install Dependencies
        run: npm install

      - name: Reset NX
        run: npx nx reset

      - name: Run All E2E Tests
        env:
          CURRENTS_PROJECT_ID: ${{secrets.CURRENTS_PROJECT_ID}}
          CURRENTS_RECORD_KEY: ${{secrets.CURRENTS_RECORD_KEY}}
          CURRENTS_CI_BUILD_ID: ${{ github.run_id }}-${{ github.sha }}
        run: npx nx run-many -t or8n
```


# Other Frameworks

Currents is focused on Playwright ecosystem, but is also compatible with other testing frameworks - Cypress, WebdriverIO, Jest, Vitest, Node.JS Test Runner and more.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FWgUWnYv3uAQVr4oLkml9%2Fcurrents-overview.png?alt=media&amp;token=3dd155dc-40e0-43a2-8ed0-424c9a453e4a" alt=""><figcaption></figcaption></figure>


# JUnit

Integrate Currents with any framework by using JUnit compatible XML reporters

Currents has flagship integrations with various testing frameworks via the dedicated reporters (like Playwright, [Jest](https://docs.currents.dev/getting-started/other-frameworks/jest), [@currents/node-test-reporter](https://docs.currents.dev/resources/reporters/currents-node-test-reporter) and [Cypress](https://docs.currents.dev/getting-started/other-frameworks/cypress)), and framework-specific instructions for [Vitest](https://docs.currents.dev/getting-started/other-frameworks/vitest).

Integration with other frameworks is possible by uploading a JUnit XML (or compatible) test results report to Currents using our CLI utilities from [@currents/cmd](https://docs.currents.dev/resources/reporters/currents-cmd) package.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2F4OSkXqAXDtov9kbU1k6n%2FJunit%20XML%20reporter.png?alt=media&amp;token=57efd7ca-fbd5-4e86-9338-5c68ed8f3f84" alt=""><figcaption><p>Send results from any framework that supports JUnit XML format</p></figcaption></figure>

> JUnit is an XML document used to represent the outcomes of automated tests. It is widely adopted for test reporting in CI/CD pipelines, allowing CI tools like Jenkins, GitHub Actions, and others to parse and display test results.
>
> JUnit reports typically contains information about:
>
> * Test suites - groups of test cases (e.g., a set of related tests)
> * Test cases - individual test scenarios with details like execution time, status (pass/fail), and optional logs (e.g., errors or skipped messages)
>
> See a detailed [example of a complete JUnit XML file](https://github.com/testmoapp/junitxml?tab=readme-ov-file#complete-junit-xml-example).

### Overview

A typical workflow for reporting JUnit XML results to Currents:

{% stepper %}
{% step %}

#### Configure testing framework

Configure your testing tool to generate the results in JUnit XML format
{% endstep %}

{% step %}

#### Run the tests

Run the tests and save the test results at a known location
{% endstep %}

{% step %}

#### Convert and upload the results to Currents

Run `currents run upload --input-format junit` with `--input-file` and `--framework` to convert the JUnit XML report to the Currents format and send it to Currents. See [Upload JUnit XML reports](https://docs.currents.dev/resources/reporters/currents-cmd/currents-convert).
{% endstep %}
{% endstepper %}

### Setup

* Install [@currents/cmd](https://docs.currents.dev/resources/reporters/currents-cmd) package

```bash
npm i @currents/cmd
```

### Run the tests

Refer to your framework documentation or contact Currents support for help with enabling JUnit reporter for your framework

<table><thead><tr><th width="232">Framework</th><th>Instructions</th></tr></thead><tbody><tr><td>Vitest</td><td><a href="https://docs.currents.dev/getting-started/other-frameworks/vitest">Vitest</a></td></tr><tr><td>NodeJS Test Runner</td><td><a href="https://nodejs.org/api/test.html#test-reporters">https://nodejs.org/api/test.html#test-reporters</a></td></tr><tr><td>WebdriverIO</td><td><a href="https://webdriver.io/docs/junit-reporter/">https://webdriver.io/docs/junit-reporter/</a></td></tr><tr><td>Cypress</td><td><a href="https://github.com/michaelleeallen/mocha-junit-reporter">https://github.com/michaelleeallen/mocha-junit-reporter</a></td></tr><tr><td>Postman (Newman)</td><td><a href="https://github.com/postmanlabs/newman?tab=readme-ov-file#junitxml-reporter">https://github.com/postmanlabs/newman?tab=readme-ov-file#junitxml-reporter</a></td></tr></tbody></table>

When running the tests, make sure to save the results at a known location - you will need to provide path to the generated files later.

### Convert and upload the results

`currents run upload --input-format junit` converts the JUnit XML report to the Currents format and uploads it. Get a [Record key](https://docs.currents.dev/guides/record-key) and [Project ID](https://docs.currents.dev/dashboard/projects) from the Currents dashboard. See [Upload JUnit XML reports](https://docs.currents.dev/resources/reporters/currents-cmd/currents-convert) for the supported frameworks.

```bash
npx currents run upload \
  --project-id=xxx \
  --key=yyy \
  --input-format=junit \
  --input-file=junit-file.xml \
  --framework=postman \
  --framework-version=v11.2.0
```

### Example

Check out the [example repository](https://github.com/currents-dev/currents-junit-xml-example) that demonstrates how to generate and report test results from various testing frameworks to Currents.

* [Postman](https://github.com/currents-dev/currents-junit-xml-example/tree/main/packages/postman)
* [Vitest](https://github.com/currents-dev/currents-junit-xml-example/tree/main/packages/vitest)
* [NodeJS Test Runner](https://github.com/currents-dev/currents-junit-xml-example/tree/main/packages/nodejs-test-runner)
* [WebdriverIO](https://github.com/currents-dev/currents-junit-xml-example/tree/main/packages/wdio)


# CI Setup


# Node.js - GitHub Actions

Running Node.js Tests on GitHub Actions

{% 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/generic-reporter/junit/nodejs-github-actions)
{% endhint %}

Here's an example workflow configuration file:

{% code title=".github/workflows /node.yml" overflow="wrap" %}

```yaml
name: Run Node.JS

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        shard: [1, 2]

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "24.x"

      - name: Install dependencies
        run: npm install

      - name: install currents
        run: npm install @currents/node-test-reporter @currents/cmd

      - name: Run tests in shard ${{ matrix.shard }}
        run: node --test --test-shard=${{ matrix.shard }}/2 --test-reporter @currents/node-test-reporter --test-reporter-destination=./report.xml tests/**.test.mjs || true && echo '✅ Script executed successfully'

      - name: Convert and upload test results to Currents.dev
        # CURRENTS_RECORD_KEY is a secret stored in the repository settings
        env:
          CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
        run: |
          npx currents run upload --project-id JOw2i3 --ci-build-id ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }} --input-format=junit --input-file=./report.xml --framework=node

```

{% endcode %}

* Get your [Record Key](https://docs.currents.dev/guides/record-key) and set [GH secret](https://docs.github.com/en/actions/reference/encrypted-secrets) variable`CURRENTS_RECORD_KEY`.
  * Or record without a stored key: with `@currents/cmd` 3.1.0 or later, give the job `permissions: id-token: write`, leave out `CURRENTS_RECORD_KEY`, and set the project ID with `--project-id` or `CURRENTS_PROJECT_ID`, not only in the reporter config. See [Record from CI with an OIDC token instead of a record key](https://docs.currents.dev/guides/record-key/record-from-ci-with-oidc).
* Set the Project ID
  * Option 1: Update the `--project-id` argument of `npx currents run upload` to [your project's id](https://docs.currents.dev/dashboard/projects/project-settings).
  * Option 2: Set it up in the [reporter config](https://docs.currents.dev/resources/reporters/currents-jest#configuration) instead.

### Explore

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>@currents/node-test-reporter</td><td></td><td></td><td><a href="https://docs.currents.dev/resources/reporters/currents-jest">@currents/jest</a></td></tr><tr><td>CI Build ID</td><td></td><td></td><td><a href="https://docs.currents.dev/guides/parallelization-guide/ci-build-id">CI Build ID</a></td></tr><tr><td>@currents/cmd</td><td></td><td></td><td></td></tr></tbody></table>


# Jest


# Your First Jest Run

Running Jest tests with Currents dashboard

Setting up Currents for running and recording Jest tests in parallel can be done seamlessly within a few minutes.

## Prerequisites

<details>

<summary>Create an Organization and a Project</summary>

After signing up for the dashboard service, you will be prompted to create a new organization and a project. You can change their names later.

<img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FOa9kh3RUY3BB5TbSjpwV%2Fcurrents-create-org.gif?alt=media&amp;token=8ec9db10-946e-48c9-ab3f-27726712e272" alt="Creating an Organization and a Project in Currents dashboard" data-size="original">

After creating a new organization and a project, you'll see on-screen instructions with your newly created **Project ID** and **Record Key.**

Select Jest from the framework selection list.

</details>

<details>

<summary>Install @currents/jest and @currents/cmd packages</summary>

```bash
npm install @currents/jest @currents/cmd --save-dev
```

**Note:** `@currents/jest` requires

* **Jest** `v29.5.0+`
* **Node.js** `v20+`, required by `@currents/cmd` 2.x

</details>

<details>

<summary>Use the Currents reporter</summary>

You have two options on how to use our reporter.

**Option 1**: Update Jest configuration file:

{% code title="jest.config.js" %}

```javascript
/** @type {import('jest').Config} */
const config = {
  reporters: ["default", "@currents/jest"], // Add this line to your config
};

module.exports = config;
```

{% endcode %}

In a package with `"type": "module"`, end the file with `export default config;` instead.

**Option 2**: Pass our reporter as an argument when executing Jest.

{% code title="package.json" %}

```json
{
  ...
  "scripts": {
    ...
    "test": "jest --reporters=@currents/jest",
  },
  ...
}
```

{% endcode %}

</details>

<details>

<summary>Update your .gitignore</summary>

Add a line in your .gitignore to avoid pushing temporary generated reports to your repository.

```
.currents
```

</details>

## Your First Jest Run

Upon running Jest tests, Currents reporter for jest generates a temporary folder containing the test results. To upload the results to Currents, you must run [currents run upload](https://docs.currents.dev/resources/reporters/currents-cmd/currents-upload)

#### Step 1: Run the tests

```sh
npx jest --reporters=@currents/jest
```

#### Step 2: Upload the results

Run the following command to upload the last results to Currents dashboard (see [currents run upload](https://docs.currents.dev/resources/reporters/currents-cmd/currents-upload))

```sh
npx currents run upload --key=XXX --project-id=YYY
```

Set the [**Record Key**](https://docs.currents.dev/guides/record-key), and [**Project ID**](https://docs.currents.dev/dashboard/projects/project-settings) obtained from Currents dashboard in the previous step.

{% hint style="info" %}
You can defined the Record Key and Project ID in the [Reporter configuration](https://docs.currents.dev/resources/reporters/currents-jest#configuration).
{% endhint %}

## Explore Your First Run

The execution results will show on the Currents dashboard. The latest report should be uploaded to Currents, and a link to the run will be displayed.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FoeTzRHuIVtdrzzYPH1wn%2Fimage.png?alt=media&amp;token=91f8ed20-bbbf-4eff-9efa-7810c0d198bb" alt=""><figcaption><p>A link to the recorded results</p></figcaption></figure>

## Good To Know

To provide reliable information about your tests, Currents run a "discovery" process - i.e. exploring the full test suite details. The discovery runs as part of the `currents run upload` command. Behind the scenes, the command runs `jest` in discovery mode.

{% hint style="info" %}
It is important to ensure that

`npx jest --reporters=@currents/jest` and `currents run upload` share the same environment variables
{% endhint %}


# Detox + Jest

Send the results of Detox + Jest tests to Currents

[Detox](https://wix.github.io/Detox/) is a gray-box end-to-end testing framework for React Native apps. Detox runs the tests with a test runner, and Jest is the recommended one.

Currents receives the results of Detox tests through the [@currents/jest](https://docs.currents.dev/resources/reporters/currents-jest) reporter and the `currents run upload` command of [@currents/cmd](https://docs.currents.dev/resources/reporters/currents-cmd). A Detox run in Currents includes:

* the result of every test attempt, including the attempts of `detox test --retries`
* the videos, screenshots and device logs that Detox records, attached to the attempt they belong to
* `detox.trace.json`, the Detox trace of the session

{% hint style="info" %}
Detox support requires `@currents/jest` 1.4.0 or later and `@currents/cmd` 1.11.0 or later. See [the example project](https://github.com/currents-dev/currents-examples/tree/main/generic-reporter/jest/detox) for a React Native app that runs Detox in GitHub Actions and reports to Currents.
{% endhint %}

### Install the packages

```bash
npm install --save-dev @currents/jest @currents/cmd
```

### Add the reporter

Add `@currents/jest` next to the Detox reporter in the Jest configuration of your Detox tests:

{% code title="e2e/jest.config.js" %}

```javascript
/** @type {import('jest').Config} */
module.exports = {
  rootDir: '..',
  testMatch: ['<rootDir>/e2e/**/*.test.js'],
  testTimeout: 120000,
  maxWorkers: 1,
  globalSetup: 'detox/runners/jest/globalSetup',
  globalTeardown: 'detox/runners/jest/globalTeardown',
  testEnvironment: 'detox/runners/jest/testEnvironment',
  reporters: ['detox/runners/jest/reporter', '@currents/jest'], // 👈🏻
  verbose: true,
};
```

{% endcode %}

### Record artifacts

Currents uploads the files that Detox records. Turn on the artifact plugins in the Detox configuration, or with the `--record-logs`, `--take-screenshots` and `--record-videos` options of `detox test`:

{% code title=".detoxrc.js" %}

```javascript
module.exports = {
  artifacts: {
    plugins: {
      log: 'all',
      screenshot: 'failing',
      video: 'failing',
    },
  },
  // ...
};
```

{% endcode %}

Detox writes `detox.trace.json` only when it records logs.

### Run the tests and upload the results

```bash
npx detox test --configuration android.emu.release --retries 1
npx currents run upload --project-id=<project id> --key=<record key>
```

Run `currents run upload` after `detox test` exits. Detox finishes writing the videos and logs only when the test run ends. See [currents run upload](https://docs.currents.dev/resources/reporters/currents-cmd/currents-upload) for the options of the command.

### Retries

`detox test --retries <n>` starts Jest again for the spec files that failed. The reporter adds the attempts of every rerun to the results of the same test, so a test that fails on the first run and passes on the rerun shows both attempts and is marked flaky in Currents.

Jest retries ([`jest.retryTimes()`](https://jestjs.io/docs/jest-object#jestretrytimesnumretries-options)) also work: they run in the same Jest process.

### Report directory

All the Jest processes of one `detox test` write their results to `.currents/<session>`, named after the Detox artifacts directory of the session. `currents run upload` reads the most recent directory in `.currents`.

To use another directory, set `reportDir` in the reporter options or the `CURRENTS_REPORT_DIR` environment variable, and pass the same directory to `currents run upload --report-dir`. The results of an earlier `detox test` stay in that directory, so remove it before each run.

{% hint style="info" %}
We recommend adding `.currents` to `.gitignore`
{% endhint %}

### Earlier versions

With `@currents/jest` before `1.4.0-beta.0`:

* `currents run upload` runs Jest to list the tests, which runs the Detox `globalSetup`. Set `selectedConfiguration` in the [Detox config file](https://wix.github.io/Detox/docs/config/overview/#config-structure) to the configuration you run the tests with, or upload fails with `Cannot determine which configuration to use from Detox config`.
* Every rerun of `detox test --retries` writes to a new report directory, or replaces the results of the earlier run when the report directory is set. Currents shows only one attempt of a retried test.
* Detox artifacts are not uploaded.

With `@currents/cmd` `1.11.0-beta.1`, runs of `pull_request` workflows in GitHub Actions show the merge commit that GitHub creates (`Merge <sha> into <sha>`) instead of the last commit of the pull request. To set the commit yourself, use the `COMMIT_INFO_*` variables, see [Overriding Commit Info](https://docs.currents.dev/dashboard/runs/commit-information#overriding-commit-info).


# Troubleshooting Jest

Troubleshooting Jest integration with Currents

{% hint style="info" %}
Run doesn't show up in Currents? Start with [Missing Runs](https://docs.currents.dev/guides/missing-runs). This page covers collecting debug information for support.
{% endhint %}

If you are experiencing issues with using `@currents/jest`, please collect more information about the failure and submit a support request via our [support channels](https://docs.currents.dev/resources/support).

### 1. Collecting Environment Information

Please collect the following information to help us effectively debug the problem:

* The associated dashboard Run URL.
* Screenshots, if applicable.
* Your setup method and configuration files.
* The exact command used to run Jest.
* Environment information (use the command below).

Use the following command to print information about your CI environment:

```bash
npx envinfo --system --binaries --browsers --npmPackages --duplicates --npmGlobalPackages
```

### 2. Activate Debug Mode

Set `DEBUG=currents*` before running `jest` to obtain detailed information about the reporter execution process.

For more details on how to troubleshoot Jest tests, refer to [their documentation](https://jestjs.io/docs/troubleshooting).


# CI Setup


# Jest - GitHub Actions

Running Jest in Parallel on GitHub Actions using Matrix Workflow

{% 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/generic-reporter/jest/github-actions)
{% endhint %}

Currents uses the native [Jest sharding](https://jestjs.io/docs/next/cli#--shard) (Jest v28+) to split the tests between multiple containers.

Here's an example workflow configuration file:

{% code title=".github/workflows /jest.yml" overflow="wrap" %}

```yaml
name: Run Jest

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        shard: [1, 2]

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "24.x"

      - name: Install dependencies
        run: npm install

      - name: Run tests in shard ${{ matrix.shard }}
        run: |
          npx jest --shard=${{ matrix.shard }}/2

      - name: Upload test results to Currents.dev
        # CURRENTS_RECORD_KEY is a secret stored in the repository settings
        env:
          CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
        run: |
          npx currents run upload --project-id mdXsz8 --ci-build-id ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}
```

{% endcode %}

* Get your [Record Key](https://docs.currents.dev/guides/record-key) and set [GH secret](https://docs.github.com/en/actions/reference/encrypted-secrets) variable`CURRENTS_RECORD_KEY`.
  * Or record without a stored key: with `@currents/cmd` 3.1.0 or later, give the job `permissions: id-token: write`, leave out `CURRENTS_RECORD_KEY`, and set the project ID with `--project-id` or `CURRENTS_PROJECT_ID`, not only in the reporter config. See [Record from CI with an OIDC token instead of a record key](https://docs.currents.dev/guides/record-key/record-from-ci-with-oidc).
* Set the Project ID
  * Option 1: Update the `--project-id` argument of `npx currents run upload` to [your project's id](https://docs.currents.dev/dashboard/projects/project-settings).
  * Option 2: Set it up in the [reporter config](https://docs.currents.dev/resources/reporters/currents-jest#configuration) instead.

### Explore

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>@currents/jest</td><td></td><td></td><td><a href="https://docs.currents.dev/resources/reporters/currents-jest">@currents/jest</a></td></tr><tr><td>CI Build ID</td><td></td><td></td><td><a href="https://docs.currents.dev/guides/parallelization-guide/ci-build-id">CI Build ID</a></td></tr><tr><td></td><td></td><td></td><td></td></tr></tbody></table>


# Vitest

Integrate Vitest with Currents using the JUnit XML reporter


# Your First Vitest Run

Running Vitest tests with Currents dashboard

Vitest doesn't have a dedicated Currents reporter. Instead, Vitest writes a JUnit XML report using its built-in `junit` reporter, and [@currents/cmd](https://docs.currents.dev/resources/reporters/currents-cmd) converts and uploads it to Currents.

## Prerequisites

<details>

<summary>Create an Organization and a Project</summary>

After signing up for the dashboard service, you will be prompted to create a new organization and a project. You can change their names later.

<img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FOa9kh3RUY3BB5TbSjpwV%2Fcurrents-create-org.gif?alt=media&amp;token=8ec9db10-946e-48c9-ab3f-27726712e272" alt="Creating an Organization and a Project in Currents dashboard" data-size="original">

After creating a new organization and a project, you'll see on-screen instructions with your newly created **Project ID** and **Record Key.**

</details>

<details>

<summary>Install @currents/cmd package</summary>

```bash
npm install @currents/cmd --save-dev
```

</details>

<details>

<summary>Enable the JUnit reporter</summary>

**Option 1**: Update the Vitest configuration file:

{% code title="vitest.config.js" %}

```javascript
import { defineConfig } from "vitest/config";

export default defineConfig({
  test: {
    reporters: ["default", "junit"],
    outputFile: {
      junit: "./results.xml",
    },
  },
});
```

{% endcode %}

**Option 2**: Pass the reporter as an argument when executing Vitest.

{% code title="package.json" %}

```json
{
  ...
  "scripts": {
    ...
    "test": "vitest run --reporter=default --reporter=junit --outputFile.junit=./results.xml",
  },
  ...
}
```

{% endcode %}

See [Vitest reporters documentation](https://vitest.dev/guide/reporters#junit-reporter) for the full list of the JUnit reporter options.

</details>

<details>

<summary>Update your .gitignore</summary>

Add the converted reports directory and the JUnit XML file to your .gitignore to avoid pushing temporary generated reports to your repository.

```
.currents
results.xml
```

</details>

## Your First Vitest Run

#### Step 1: Run the tests

```sh
npx vitest run
```

If you passed the reporter in the `test` script (Option 2), run `npm test` instead.

Vitest saves the JUnit XML report at the location configured by `outputFile.junit` - `./results.xml` in the examples above.

#### Step 2: Convert and upload the results

Run `currents run upload` with `--input-format junit` to convert the JUnit XML report to the Currents format and send it to the Currents dashboard (see [Upload JUnit XML reports](https://docs.currents.dev/resources/reporters/currents-cmd/currents-convert)). Set `--framework-version` to the Vitest version you're running.

```sh
npx currents run upload \
  --key=XXX \
  --project-id=YYY \
  --input-format=junit \
  --input-file=./results.xml \
  --framework=vitest \
  --framework-version=v3.2.4
```

Set the [**Record Key**](https://docs.currents.dev/guides/record-key) and [**Project ID**](https://docs.currents.dev/dashboard/projects/project-settings) obtained from Currents dashboard in the previous step.

## Explore Your First Run

The execution results will show on the Currents dashboard. A link to the run is printed when the upload completes.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FoeTzRHuIVtdrzzYPH1wn%2Fimage.png?alt=media&amp;token=91f8ed20-bbbf-4eff-9efa-7810c0d198bb" alt=""><figcaption><p>A link to the recorded results</p></figcaption></figure>

## Good To Know

`vitest run` exits with a non-zero code when tests fail, which stops a CI job before the results are converted and uploaded. Run the conversion and upload steps unconditionally - see [Vitest - GitHub Actions](https://docs.currents.dev/getting-started/other-frameworks/vitest/ci-setup/vitest-github-actions) for an example.

## Example

Check out the [Vitest example](https://github.com/currents-dev/currents-junit-xml-example/tree/main/packages/vitest) in the JUnit XML example repository.


# Troubleshooting Vitest

Troubleshooting Vitest integration with Currents

If you are experiencing issues with reporting Vitest results, please collect more information about the failure and submit a support request via our [support channels.](https://docs.currents.dev/resources/support)

### 1. Collecting Environment Information

Please collect the following information to help us effectively debug the problem:

* The associated dashboard Run URL
* The JUnit XML file produced by Vitest
* Your setup method and configuration files
* The exact commands used to run `vitest` and `currents run upload`
* Environment information (use the command below)

Use the following command to print information about your CI environment

```bash
npx envinfo --system --binaries --browsers --npmPackages --duplicates --npmGlobalPackages
```

### 2. Activate Debug Mode

Pass `--debug` to `currents run upload`, or set `CURRENTS_DEBUG=true`, to print detailed information about the conversion and upload process.

### 3. Common Issues

For a run that doesn't show up in Currents, see [Missing Runs](https://docs.currents.dev/guides/missing-runs).

For more details on how to troubleshoot Vitest tests, refer to [their documentation](https://vitest.dev/guide/debugging).


# CI Setup


# Vitest - GitHub Actions

Running Vitest in Parallel on GitHub Actions using Matrix Workflow

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

[https://github.com/currents-dev/currents-junit-xml-example](https://github.com/currents-dev/currents-junit-xml-example/tree/main/packages/vitest)
{% endhint %}

Currents uses the native [Vitest sharding](https://vitest.dev/guide/cli#shard) to split the tests between multiple containers. Each shard writes its own JUnit XML report, converts it and uploads it under a shared [CI Build ID](https://docs.currents.dev/guides/parallelization-guide/ci-build-id).

Here's an example workflow configuration file:

{% code title=".github/workflows /vitest.yml" overflow="wrap" %}

```yaml
name: Run Vitest

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-latest

    strategy:
      fail-fast: false
      matrix:
        shard: [1, 2]

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "24.x"

      - name: Install dependencies
        run: npm install

      - name: Run tests in shard ${{ matrix.shard }}
        run: npx vitest run --shard=${{ matrix.shard }}/2 --reporter=default --reporter=junit --outputFile.junit=./results.xml

      # `vitest run` exits non-zero on test failures - report the results anyway
      - name: Convert and upload test results to Currents.dev
        if: always()
        # CURRENTS_RECORD_KEY is a secret stored in the repository settings
        env:
          CURRENTS_RECORD_KEY: ${{ secrets.CURRENTS_RECORD_KEY }}
        run: |
          npx currents run upload --project-id XXXXXX --ci-build-id ${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }} --input-format=junit --input-file=./results.xml --framework=vitest --framework-version=v3.2.4
```

{% endcode %}

* Get your [Record Key](https://docs.currents.dev/guides/record-key) and set [GH secret](https://docs.github.com/en/actions/reference/encrypted-secrets) variable`CURRENTS_RECORD_KEY`.
  * Or record without a stored key: with `@currents/cmd` 3.1.0 or later, give the job `permissions: id-token: write`, leave out `CURRENTS_RECORD_KEY`, and set the project ID with `--project-id` or `CURRENTS_PROJECT_ID`, not only in the reporter config. See [Record from CI with an OIDC token instead of a record key](https://docs.currents.dev/guides/record-key/record-from-ci-with-oidc).
* Update the `--project-id` argument of `npx currents run upload` to [your project's id](https://docs.currents.dev/dashboard/projects/project-settings).
* Set `--framework-version` to the Vitest version installed in the workflow.

### Explore

<table data-view="cards"><thead><tr><th></th><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>@currents/cmd</td><td></td><td></td><td><a href="https://docs.currents.dev/resources/reporters/currents-cmd">@currents/cmd</a></td></tr><tr><td>CI Build ID</td><td></td><td></td><td><a href="https://docs.currents.dev/guides/parallelization-guide/ci-build-id">CI Build ID</a></td></tr><tr><td>Upload JUnit XML reports</td><td></td><td></td><td><a href="https://docs.currents.dev/resources/reporters/currents-cmd/currents-convert">Upload JUnit XML reports</a></td></tr></tbody></table>


# Cypress


# Your First Cypress Run

Running Cypress tests in parallel with Currents Dashboard

{% hint style="warning" %}
**We are suspending our support of Cypress test runner version 13+**

We will continue to support [prior versions](https://docs.currents.dev/getting-started/other-frameworks/cypress/integrating-with-cypress/alternative-cypress-binaries) of Cypress.

[Read more](https://currents.dev/posts/v13-blocking)
{% endhint %}

Setting up Currents for running and recording cypress tests in parallel can be done seamlessly within a few minutes.

Here's an overview of what steps you'll need to take to start running cypress tests in parallel using the Currents dashboard:

* Create an organization and a project
* Install `cypress` and [`cypress-cloud`](https://github.com/currents-dev/cypress-cloud) npm packages
* Create a new configuration file `currents.config.js` with the newly created `projectId` and a record key
* Update `cypress.config.js` to include the `cypress-cloud/plugin` plugin
* Use `cypress-cloud` CLI command to create your cypress run
* Update your CI provider configuration

### Create New Organization and a Project

After signing up for the dashboard service, you will be prompted to create a new organization and a project. You can change the name later.

After creating a new organization and a project, you'll see on-screen instructions with your newly created `projectId`

### Install `cypress` and `cypress-cloud`

```bash
npm install cypress cypress-cloud
```

### Create `currents.config.js`

Create a new configuration file and put it in your project's root folder:

```javascript
// currents.config.js
module.exports = {
  projectId: "Ij0RfK", // the projectId from https://app.currents.dev
  recordKey: "xxx", // the record key from https://app.currents.dev
};
```

### Install cypress-cloud plugin

{% tabs %}
{% tab title="cypress.config.js" %}

```javascript
const { defineConfig } = require('cypress')
const { cloudPlugin } = require("cypress-cloud/plugin");

module.exports = defineConfig({
  // ...
  e2e: {
    setupNodeEvents(on, config) {
      return cloudPlugin(on, config);
    },
  }
})
```

{% endtab %}

{% tab title="cypress.config.ts" %}

```typescript
import { defineConfig } from 'cypress'
import { cloudPlugin } from 'cypress-cloud/plugin'
export default defineConfig({
  // ...
  e2e: {
    setupNodeEvents(on, config) {
      return cloudPlugin(on, config);
    },
  }
})
```

{% endtab %}

{% tab title="cypress.json" %}
`cypress-cloud` requires cypress version 10.0.0+. Please refer to our [legacy integration](https://docs.currents.dev/resources/reporters/currents-cli) for the setup instructions
{% endtab %}
{% endtabs %}

### Create your first cypress run

Run `currents` command to create your first cypress run in Currents dashboard.

<pre><code><strong>npx cypress-cloud run \
</strong>--parallel \
--record \
--ci-build-id hello-currents
</code></pre>

See all the available options `npx cypress-cloud --help`.

Running this command will create a new run in Currents dashboard.

![Newly Created Cypress Run](https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fw6pxbR9r7CUhobXFsiKg%2FScreenshot%202026-01-08%20at%2017.02.08.png?alt=media\&token=5b09a1c5-a413-4782-b290-a82981e2302e)

{% hint style="info" %}
Learn more about

* [Integration with Cypress](https://docs.currents.dev/getting-started/other-frameworks/cypress/integrating-with-cypress)
* [Record Key](https://docs.currents.dev/guides/record-key)
* [CI Build ID](https://docs.currents.dev/guides/parallelization-guide/ci-build-id)
  {% endhint %}

### Update your CI provider configuration <a href="#update-your-ci-provider-configuration" id="update-your-ci-provider-configuration"></a>

To unlock the full power of Currents dashboard, update your CI provider configuration to use Currents for running your cypress tests in parallel. Please read our [Parallelization Guide](https://currents.dev/readme/guides/parallelization) and check out few [CI Setup examples](https://currents.dev/readme/ci-setup) for popular CI tools.\ <br>

###


# Upload Cypress 13+ Results

Report Cypress 13 and later results to Currents by uploading Cypress's run results or JUnit reports with currents run upload, from the same or a later CI job

`currents run upload` reports Cypress 13 and later results to Currents without a Currents package in the Cypress project. Cypress writes its results to files, and `currents run upload` converts and uploads them, in the same CI job or in a later one. Use it when [`cypress-cloud`](https://docs.currents.dev/resources/reporters/cypress-cloud) does not support your Cypress version (see [Compatibility](https://docs.currents.dev/getting-started/other-frameworks/cypress/integrating-with-cypress/compatibility)).

There are two formats to upload:

|             | Cypress run results (`cypress-json`)    | JUnit XML (`junit --framework cypress`) |
| ----------- | --------------------------------------- | --------------------------------------- |
| Attempts    | Every attempt of a test                 | The last attempt only                   |
| Flaky tests | A test that passed on a retry is flaky  | Never flaky                             |
| Screenshots | Each failure screenshot, on its attempt | Added to the reports by a script        |
| Videos      | The spec video                          | None                                    |

Use the Cypress run results unless your CI already collects JUnit reports.

## Prerequisites

* Cypress 13 or later.
* `@currents/cmd` 2.3.0 or later and Node.js 20 or later, in the job that uploads.
* A Currents project ID and [record key](https://docs.currents.dev/guides/record-key).

## Upload Cypress run results

{% stepper %}
{% step %}

### Save the run results

Add an `after:run` handler to `cypress.config.js`. It writes Cypress's run results to a JSON file when the run ends:

{% code title="cypress.config.js" %}

```javascript
const fs = require('fs');

module.exports = {
  e2e: {
    setupNodeEvents(on) {
      on('after:run', (results) => {
        fs.mkdirSync('results', { recursive: true });
        fs.writeFileSync(
          `results/cypress-results-${process.env.CI_NODE_INDEX ?? 1}.json`,
          JSON.stringify(results)
        );
      });
    },
  },
};
```

{% endcode %}

The file name includes the machine index, so the files of parallel CI jobs do not overwrite each other. `CI_NODE_INDEX` is the GitLab CI variable; use the equivalent of your CI provider. The result of `cypress.run()` has the same format.
{% endstep %}

{% step %}

### Run Cypress

```bash
npx cypress run
```

{% endstep %}

{% step %}

### Upload the results

Run the command from the Cypress project folder. It reads the screenshots and videos relative to it.

```bash
npx @currents/cmd run upload \
  --key <record-key> \
  --project-id <project-id> \
  --input-format cypress-json \
  --input-file "results/cypress-results-*.json"
```

`--framework` is not needed. The Cypress version comes from the file.

`npx cypress run` exits with an error when a test fails. Upload the results in a step that runs then too, for example in GitLab's `after_script` or in a GitHub Actions step with `if: ${{ !cancelled() }}`.
{% endstep %}
{% endstepper %}

The command prints `Run created:` and the link to the run. The run shows each spec file with its tests, every attempt, and the screenshots of each failed attempt.

## Upload JUnit reports

Configure Cypress's built-in `junit` reporter to write one report per spec file:

{% code title="cypress.config.js" %}

```javascript
module.exports = {
  reporter: 'junit',
  reporterOptions: {
    mochaFile: 'results/junit-[hash].xml',
    includePending: true,
    testsuitesTitle: 'e2e',
  },
};
```

{% endcode %}

* `[hash]` gives each spec file its own report. Without it, each spec overwrites the report of the previous one.
* `includePending: true` keeps skipped tests in the reports.
* `testsuitesTitle` is the group name in Currents.

Delete the reports of earlier runs, then run Cypress. The reporter adds one file per spec file and does not remove old ones, so `results/*.xml` would also match reports of specs that did not run this time.

```bash
rm -rf results
npx cypress run
```

Upload the reports with `--framework cypress`:

```bash
npx @currents/cmd run upload \
  --key <record-key> \
  --project-id <project-id> \
  --input-format junit \
  --input-file "results/*.xml" \
  --framework cypress
```

The JUnit reports do not refer to the screenshots. To upload them, run [`attach-screenshots.js`](https://github.com/currents-dev/currents-examples/blob/main/cypress/gitlab-upload/attach-screenshots.js) from the example before the upload. It adds each failure screenshot to its test as an [artifact](https://docs.currents.dev/resources/reporters/currents-cmd/currents-convert#artifacts).

## Upload from a later CI job

The Cypress job needs no Currents package, variable or configuration. Keep the result files, screenshots and videos as job artifacts, also when the Cypress job fails (on GitLab, `artifacts: when: always`; the default saves them only when the job succeeds). Upload them from a later job that runs even when the Cypress job fails. Uploads with the same [CI build ID](https://docs.currents.dev/guides/parallelization-guide/ci-build-id) go to the same run, so one upload job can upload the files of several parallel Cypress jobs.

The [GitLab CI example](https://github.com/currents-dev/currents-examples/tree/main/cypress/gitlab-upload) runs Cypress on 2 parallel jobs and uploads the results of both from a later job.

{% hint style="warning" %}
Cypress stops before it runs any test, with `We've detected that you're using a 3rd party library that is not supported by Cypress: cypress-cloud`, when its job has `CURRENTS_RECORD_KEY`, `CURRENTS_PROJECT_ID` or `CURRENTS_API_URL` set. GitLab passes project CI/CD variables to every job. Store the record key in a CI/CD variable with another name, for example `CURRENTS_UPLOAD_KEY`, and set `CURRENTS_RECORD_KEY` from it in the upload job only:

```yaml
currents:
  variables:
    CURRENTS_PROJECT_ID: <project-id>
    CURRENTS_RECORD_KEY: $CURRENTS_UPLOAD_KEY
```

Set `CURRENTS_PROJECT_ID`, and `CURRENTS_API_URL` if you use it, in the `variables` of the upload job as above, not as CI/CD variables of the project.

`CURRENTS_UPLOAD_KEY` still reaches every job of the project, the Cypress jobs too. To give it to the upload job only, set an environment scope on the CI/CD variable and the same `environment` on the upload job.

Checked with the `cypress/included` images 14.2.0, 14.5.4 and 16.2.0.
{% endhint %}

## Limits

See [Limitations of uploaded Cypress 13+ results](https://docs.currents.dev/getting-started/other-frameworks/cypress/integrating-with-cypress/compatibility#limitations-of-uploaded-cypress-13-results).

The other options of the command are on [currents run upload](https://docs.currents.dev/resources/reporters/currents-cmd/currents-upload).


# Integrating with Cypress

Overview of tools available for integrating cypress with Currents or Sorry Cypress

{% hint style="warning" %}
**We are suspending our support of Cypress test runner version 13+**

We will continue to support [prior versions](https://docs.currents.dev/getting-started/other-frameworks/cypress/integrating-with-cypress/alternative-cypress-binaries) of Cypress.

[Read more](https://currents.dev/posts/v13-blocking)
{% endhint %}

Currents and Sorry Cypress provide two ways to integrate with cypress runner using the following npm packages:

* [@currents/cli](https://docs.currents.dev/resources/reporters/currents-cli) (and its "community" edition [cy2](https://www.npmjs.com/package/cy2))
* [cypress-cloud](https://docs.currents.dev/resources/reporters/cypress-cloud)

Both solutions are open-source tools that provide an executable + a programmatic API for integrating cypress with cloud orchestration and recording services like Currents or Sorry Cypress.

The tools use cypress behind the scenes and provide the same flags and configuration options as the original cypress runner.

### What is the difference between @currents/cli and cypress-cloud?

**@cypress/cli** works by rerouting orchestration and recording network requests to currents.dev (or sorry-cypress) servers. It uses the original, "native" orchestration protocol defined by the cypress runner. In Feb 2023, Cypress.io team decided to [restrict access](#user-content-fn-1)[^1] to its internal orchestration and recording protocol, preventing the use of @currents/cli (affected versions are 12.6.0+).

**cypress-cloud** implements its own parallelization and recording protocol and runs cypress in "offline" mode, without tinkering with the cypress internals. The package uses the conventional public APIs that are available for every developer and that are being used by hundreds of [plugins and complimentary tools](https://docs.cypress.io/plugins) of Cypress ecosystem. It is compatible with version 10.0.0+ until version 12.7.4 using the [Alternative Cypress Binaries](https://docs.currents.dev/getting-started/other-frameworks/cypress/integrating-with-cypress/alternative-cypress-binaries) for the latest ones.

### What package should I use?

We recommend using **cypress-cloud** for all new installations.

[^1]: ...by showing "Cypress does not support recording test results to this third party service."


# Compatibility

Integrating Cypress with Currents - compatibility table

{% hint style="warning" %}
**We are suspending our support of Cypress test runner version 13+**

We will continue to support [prior versions](https://docs.currents.dev/getting-started/other-frameworks/cypress/integrating-with-cypress/alternative-cypress-binaries) of Cypress.

[Read more](https://currents.dev/posts/v13-blocking)
{% endhint %}

To report Cypress 13 and later results, upload them with `currents run upload`. See [Upload Cypress 13+ Results](https://docs.currents.dev/getting-started/other-frameworks/cypress/upload-cypress-13-results) and the [limitations of uploaded results](#limitations-of-uploaded-cypress-13-results).

We provide several packages to integrate cypress runner with Currents (or Sorry Cypress) orchestration services:

* ☁️ [cypress-cloud](https://github.com/currents-dev/cypress-cloud) - standalone runner for Sorry Cypress and Currents
* \[deprecated] [cy2](https://github.com/sorry-cypress/cy2) - package for integrating arbitrary cloud orchestration services with cypress
* \[deprecated] [@currents/cli](https://www.npmjs.com/package/@currents/cli) - a dedicated package for integrating cypress with Currents cloud service

Please use the table below to select the version of the compatible package.

#### Currents Customers

<table><thead><tr><th>Cypress Version</th><th width="242.33333333333331">@currents/cli [deprecated]</th><th>cypress-cloud</th></tr></thead><tbody><tr><td>13.2.0+</td><td>not supported</td><td>not supported</td></tr><tr><td>13.1.0</td><td>not supported</td><td>not supported</td></tr><tr><td>12.6.0+ (<a href="https://docs.currents.dev/getting-started/other-frameworks/cypress/integrating-with-cypress/alternative-cypress-binaries">Alternative Binaries</a>)</td><td>not supported</td><td>1.4.1+</td></tr><tr><td>12.1.0+</td><td>4.0.3+</td><td>1.4.1+</td></tr><tr><td>12.0.0+</td><td>3.1.3+</td><td>1.4.1+</td></tr><tr><td>11.0.0+</td><td>3.0.0+</td><td>1.4.1+</td></tr><tr><td>6.7.0+</td><td>any version</td><td>not supported</td></tr></tbody></table>

#### Sorry Cypress Users

<table><thead><tr><th>Cypress Version</th><th width="242.33333333333331">cy2 [deprecated]</th><th>cypress-cloud</th></tr></thead><tbody><tr><td>13.2.0+</td><td>not supported</td><td>not supported</td></tr><tr><td>13.1.0</td><td>not supported</td><td>not supported</td></tr><tr><td>12.6.0+ (<a href="https://docs.currents.dev/getting-started/other-frameworks/cypress/integrating-with-cypress/alternative-cypress-binaries">Alternative Binaries</a>)</td><td>not supported</td><td>1.4.1+</td></tr><tr><td>12.1.0+</td><td>4.0.6+</td><td>1.4.1+</td></tr><tr><td>11.0.0+</td><td>4.0.1+</td><td>1.4.1+</td></tr><tr><td>6.7.0+</td><td>any version</td><td>not supported</td></tr></tbody></table>

#### **NX Users**

NX users can use [@currents/nx](https://www.npmjs.com/package/@currents/nx) plugin to conveniently integrate Currents or Sorry Cypress with their project

<table><thead><tr><th width="152.5">Cypress</th><th align="right">@currents/nx</th></tr></thead><tbody><tr><td>12.6.0+ (<a href="https://docs.currents.dev/getting-started/other-frameworks/cypress/integrating-with-cypress/alternative-cypress-binaries">Alternative Binaries</a>)</td><td align="right">2.0.0+</td></tr><tr><td>12.1.0+</td><td align="right">2.0.0+</td></tr><tr><td>12.0.0+</td><td align="right">0.2.1+</td></tr><tr><td>11.0.0+</td><td align="right">0.1.0+</td></tr><tr><td>6.7.0+</td><td align="right">any version</td></tr></tbody></table>

## Limitations of uploaded Cypress 13+ results

Results uploaded with `currents run upload` come from files that Cypress writes after the run. Compared with `cypress-cloud`:

* There is no orchestration. Split the spec files between CI machines yourself.
* There is no live progress. The run appears when the upload runs.
* The JUnit format keeps the last attempt of each test only, so tests are never flaky. Upload Cypress's run results (`cypress-json`) to keep every attempt. A test is flaky only when Cypress retries are enabled and it passed on a retry.
* Cypress keeps the error of the last failed attempt only. Earlier failed attempts have no error message.
* Cypress reports one duration for all attempts of a test. Each attempt gets an equal part of it.
* There are no steps or command log.
* A spec file that Cypress could not load, for example because of a syntax error, has no tests in the results. `currents run upload` prints a warning that names it, and the spec file is not in the run.
* Uploading the results of a run again, for example by retrying the upload job, adds the screenshots and videos a second time.


# Alternative Cypress Binaries

Using alternative Cypress Binaries

{% hint style="info" %}
**We are suspending our support of Cypress test runner version 13+**

We will continue to support prior versions of Cypress.
{% endhint %}

Following the blocking of [Sorry Cypress, Currents and DeploySentintel](https://currents.dev/posts/v13-blocking) packages, we are suspending our support of Cypress 13+.

We apologize for the interruption of your workflows and possible downtime caused by the sudden blocking on November 7. We received no communication from Cypress.io team about the intent to release the breaking change.

We will continue supporting prior versions of the MIT-licensed Cypress test runner using independent, block-free versions of binaries.

***

As a background - Cypress installation has 2 components:

* an [npm package](https://www.npmjs.com/package/cypress) `cypress`- a lightweight NodeJS wrapper that parses command line flags, downloads and runs an OS/platform-specific Electron binary application.
* Electron application (binary) - an OS/platform-specific binary code, it is usually pre-installed and cached on docker images or is being downloaded by the npm package.

We are hosting independent versions of the electron app and docker images with pre-installed binaries that you can use without the risk of being blocked. The supported versions:

| Version          | Supported OS-Architecture |
| ---------------- | ------------------------- |
| 9.0.0 - 9.7.0    | All                       |
| 10.0.0 - 10.11.0 | All                       |
| 11.0.0 - 11.1.0  | All                       |
| 12.0.0 - 12.17.3 | `linux-x64, linux-arm64`  |
| 12.17.4          | All                       |

{% hint style="success" %}
Missing specific version, OS or architecture? Not sure what version to use? Let us know!
{% endhint %}

#### Using the alternative binaries

Use a one-liner to install alternative cypress binaries:

```
CYPRESS_DOWNLOAD_MIRROR=https://cy-cdn.currents.dev npx cypress install --force
```

*Alternatively*, follow the step-by-step instructions below:

* Pin `cypress` version to one of the supported versions in `package.json`
  * For example: `"cypress": "12.17.0"`
  * Update your package manager lock file
* Clean the existing Cypress binary `npx cypress cache clear`
* Define [download mirror](https://docs.cypress.io/guides/references/advanced-installation#Mirroring) by configuring environment variable:
  * Linux: `export CYPRESS_DOWNLOAD_MIRROR=https://cy-cdn.currents.dev`
  * Windows cmd: `set CYPRESS_DOWNLOAD_MIRROR=https://cy-cdn.currents.dev`
  * Window PowerShell: `$env:CYPRESS_DOWNLOAD_MIRROR = "https://cy-cdn.currents.dev"`
* Reinstall Cypress App binary from the alternative mirror: `npx cypress install`
* Run your workflows as usual

#### Using Docker images with pre-installed binaries

Use the following [docker image](https://hub.docker.com/r/currentsdev/cypress-included) that has pre-installed, block-free binaries to run your workflows:

`docker pull currentsdev/cypress-included:<version>`

#### Examples

* GitHub Actions [example workflow](https://github.com/currents-dev/currents-examples/blob/main/cypress/github-actions/.github/workflows/currents.yml) with `cypress-io/github-action@v6`

Please contact our [support channels](https://docs.currents.dev/resources/support) for additional information and assistance.


# CI Setup


# Cypress - GitHub Actions

Using GitHub Actions Matrix for parallelizing Cypress tests

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

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

By using [GitHub Actions matrix execution strategy](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix), you can create multiple containers that will run Cypress tests in parallel. Currents orchestrates the tests between multiple containers, applying intelligent optimizations to reduce the overall runtime of your workflow, and records screenshots and videos for later troubleshooting.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FOt3a2yA71OFq87TCZ6cx%2FCI%20Runners.png?alt=media&amp;token=70fa657e-4304-4b0d-a77d-e984aa7af2b4" alt="Tests Parallelization with Github Actions"><figcaption><p>Tests Parallelization with Github Actions</p></figcaption></figure>

Please take a look at the [example repository](https://github.com/currents-dev/currents-examples/tree/main/cypress/github-actions) that showcases running cypress tests in parallel using GitHub Actions.

{% code overflow="wrap" %}

```yaml
name: Cypress Tests

on:
  push:

jobs:
  cypress-tests:
    runs-on: ubuntu-20.04
    strategy:
      fail-fast: false
      matrix:
        # 👉🏻 run 3 copies of the current job in parallel
        containers: [1, 2, 3]
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        # 👉🏻  populate commit message for merge commits
        # see https://currents.dev/readme/ci-setup/github-actions
        # with:
        #  ref: ${{ github.event.pull_request.head.sha }}

      - uses: actions/setup-node@v3
        with:
          node-version: "24.x"

      - name: Install dependencies
        run: |
          npm ci

      # More about the blocking:
      # - https://currents.dev/posts/v13-blocking
      # - https://currents.dev/readme/integration-with-cypress/alternative-cypress-binaries
      - name: Unblock Cypress
        run: |
          echo 🕊️ Download Free Cypress
          CYPRESS_DOWNLOAD_MIRROR=https://cy-cdn.currents.dev npx cypress install --force

          echo ✅ Verify Cypress
          npx cypress verify

          echo 👀 Cypress Cache
          npx cypress cache list
          npx cypress cache path

      # 
      - name: Run Cypress on Currents.dev
        env:
          # enable verbose logging for cypress-io/github-action
          DEBUG: \@cypress/github-action
        uses: cypress-io/github-action@v6
        continue-on-error: true

        with:
          # 🔥 Set to false to prevent restoring cachedCypress binary
          install: false
          command: |
            npx cypress-cloud --record --parallel --browser chrome --key ${{ secrets.CURRENTS_RECORD_KEY }} --ci-build-id "${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt}}"

      - name: Cancel the run if workflow is cancelled
        if: ${{ cancelled() }}
        uses: currents-dev/cancel-run-gh-action@v1
        with:
          api-token: ${{ secrets.CURRENTS_API_KEY }}
          github-run-id: ${{ github.run_id }}
          github-run-attempt: ${{ github.run_attempt }}
```

{% endcode %}

The example [workflow config file](https://github.com/currents-dev/currents-examples/blob/main/cypress/github-actions/.github/workflows/currents.yml):

* runs 3 containers with cypress tests in parallel
* uses [Custom Test Command](https://github.com/cypress-io/github-action#custom-test-command) to run `cypress-cloud` for recording test results and parallelization with [Currents.dev](https://currents.dev)
* Note: set the `projectId` in `currents.config.js` (you can obtain the project id from [Currents.dev](https://app.currents.dev) in Project Settings)
* Note: install `cypress-cloud/plugin` in `cypress.config.js`
* Note: use CLI arguments to customize your cypress runs, e.g.: `cypress-cloud run --parallel --record --key <your currents.dev key> --group groupA`
* Note: create an organization, get your record key on [Currents.dev](https://app.currents.dev) and set [GH secret](https://docs.github.com/en/actions/reference/encrypted-secrets) variable `CURRENTS_RECORD_KEY`


# Cypress - GitLab CI/CD

Running Cypress test in parallel on GitLab

{% hint style="info" %}
TL;DR Take a look at an example repository:

<https://gitlab.com/currents.dev/gitlab-currents-example>
{% endhint %}

GitLab CI/CD platform allows effectively running your Playwright and Cypress test in parallel, using multiple containers and Currents for tests orchestration.

To run Cypress tests in parallel, define [`parallel`](https://docs.gitlab.com/ee/ci/jobs/job_control.html#parallelize-large-jobs) job parameters in GitLab CI/CD pipeline configuration file.

GitLab will run the jobs on multiple containers - each container will run a unique set of tests using Currents orchestration service. Currents applies intelligent optimizations and sorts the test to reduce the overall runtime of the pipeline.

![Using Gitlab CI/CD parallel jobs for running cypress tests in parallel](https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgr9aCc5gbP2iyT3FRyH1%2FCleanShot%202022-02-18%20at%2023.03.15.png?alt=media\&token=ea1627fd-eff2-436f-bc05-871fa919e3f1)


# Cypress - Jenkins

Running Cypress tests in parallel with Jenkins and Currents Dashboard

Here's an example of Jenkins pipeline that is running cypress tests in parallel on 2 workers and is connected to Currents Dashboard for orchestrating the parallel runs and reporting the results.

The pipeline will be running 2 workers, based on `cypress/base:16` Docker image. Those workers will run all the tests in parallel.

The steps are:

* Use `cypress/base:18` as the base image
* Install the necessary dependencies: `cypress` and `cypress-cloud`
* Populate the environment variable `CURRENTS_RECORD_KEY` using [Jenkins Credentials Store](https://jenkins.io/doc/book/using/using-credentials/). Learn more about [Record Key](https://docs.currents.dev/guides/record-key)
* Run cypress tests on 2 workers, using CI Build ID for "connecting" the workers to the same parallel run.

{% code overflow="wrap" %}

```
npx cypress-cloud run --parallel --record --key ${env.CURRENTS_RECORD_KEY} --ci-build-id ${env.BRANCH_NAME}-${env.BUILD_ID}"
```

{% endcode %}

Here's the full Jenkins pipeline configuration file:

{% code overflow="wrap" %}

```groovy
pipeline {
  agent {
    // this image provides everything needed to run Cypress
    docker {
      image 'cypress/base:18'
    }
  }

  stages {
    // installs node dependencies and Cypress binary
    stage('build') {
      steps {
        echo "Running build ${env.BUILD_ID} on ${env.JENKINS_URL}"
        sh 'npm install cypress cypress-cloud'
      }
    }

    // this stage runs cypress tests, and each agent uses the workspace
    // from the previous stage
    stage('cypress parallel tests') {
      environment {
        // see https://jenkins.io/doc/book/using/using-credentials/
        CURRENTS_RECORD_KEY = credentials('currents-record-key')
        // Prevent deletion of videos to avoid race condition
        CYPRESS_trashAssetsBeforeRuns = 'false'
      }

      // Run parallel workers, see:
      // https://jenkins.io/doc/book/pipeline/syntax/#parallel
      parallel {
        // each worker is running the same command, 
        // Currents Dashboard will orchestrate the tests between 
        // the workers
        stage('tester A') {
          steps {
            echo "Running build ${env.BUILD_ID}"
            sh "npx cypress-cloud run --parallel --record --key ${env.CURRENTS_RECORD_KEY} --ci-build-id ${env.BRANCH_NAME}-${env.BUILD_ID}"
          }
        }

        // second tester runs the same command
        stage('tester B') {
          steps {
            echo "Running build ${env.BUILD_ID}"
            sh "npx cypress-cloud run --parallel --record --key ${env.CURRENTS_RECORD_KEY} --ci-build-id ${env.BRANCH_NAME}-${env.BUILD_ID}"
          }
        }
      }

    }
  }
}
```

{% endcode %}


# Cypress - CircleCI

Running Cypress tests in parallel on CircleCI and Currents dashboard

{% 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/cypress/circleci)
{% endhint %}

This is an example repository that showcases using [CircleCI](https://circleci.com/) with [Currents.dev](https://currents.dev/).

We are hosting independent versions of the Cypress App and [docker images](https://hub.docker.com/r/currentsdev/cypress-included) with pre-installed binaries. Please refer to the [documentation](https://currents.dev/readme/integration-with-cypress/alternative-cypress-binaries) for the list of supported binaries and versions.

The example [config file](https://github.com/currents-dev/currents-examples/blob/main/cypress/circleci/.circleci/config.yml) installs the custom Cypress App and runs 3 containers with Cypress tests in parallel using various setup scenarios.

### Prerequisites

* Create an account at https\:/app.currents.dev.
* Obtain **ProjectId** and **Record Key**.
* Set `CURRENTS_RECORD_KEY`:
  * create [CircleCI context](https://circleci.com/docs/guides/security/contexts/) and set `CURRENTS_RECORD_KEY`.
  * alternatively, set [Environment variable](https://circleci.com/docs/guides/security/env-vars/) `CURRENTS_RECORD_KEY`
* Follow the setup instructions at [cypress-cloud](https://docs.currents.dev/resources/reporters/cypress-cloud) to create `currents.config.js` set your `projectId`

### Bare CircleCI configuration

Please refer to the setup scenario that fits your needs.

#### Use Docker image with pre-installed Cypress

CircleCI configuration that uses Docker image with pre-installed cypress app. Refer to the [documentation](https://currents.dev/readme/integration-with-cypress/alternative-cypress-binaries) for the list of supported binaries and versions.

```
version: 2.1

jobs:
  # Use pre-built image with alternative Cypress binary
  noorbs currents-image:
    parallelism: 3
    docker:
      - image: currentsdev/cypress-included:12.17.4
    steps:
      - checkout
      - run:
          name: Install Dependencies
          command: npm ci
      - run:
          name: Run tests
          command: npx cypress-cloud run --parallel --record --key $CURRENTS_RECORD_KEY

workflows:
  noorbs:
    jobs:
      - noorbs currents-image:
          context: currents
```

#### Explicitly downloading alternative Cypress binary

CircleCI configuration that explicitly downloads alternative Cypress binary. Refer to the [documentation](https://currents.dev/readme/integration-with-cypress/alternative-cypress-binaries) for the list of supported binaries and versions.

```
version: 2.1

jobs:
  # Explicitly download Cypress binary
  noorbs explicit-download:
    parallelism: 3
    docker:
      - image: cypress/base:18.16.1
    steps:
      - checkout
      - run:
          name: Install dependencies
          command: npm ci
      - run:
          name: Download Alternative Cypress Binaries
          command: CYPRESS_DOWNLOAD_MIRROR=https://cy-cdn.currents.dev npx cypress install --force
      - run:
          name: Run tests
          command: npx cypress-cloud run --parallel --record --key $CURRENTS_RECORD_KEY

workflows:
  noorbs:
    jobs:
      - noorbs explicit-download:
          context: currents
```

### Using Cypress Orb with default executor

[Cypress Orb](https://circleci.com/developer/orbs/orb/cypress-io/cypress) has pre-defined commands that facilitate creating CircleCI configuration. The examples below show how to integrate Cypress tests with Currents using Cypress Orb and various setup scenarios.

The examples below use [Custom Test Command](https://github.com/currents-dev/currents-examples/blob/main/cypress/circleci/.circleci/config.yml#L9) to run `cypress-cloud` for recording test results and parallelization with [Currents.dev](https://currents.dev/)

#### Using `cypress/default` executor example

The configuration below uses the default `cypress/default` [CircleCI executor](https://circleci.com/docs/executor-intro/) and installs custom Cypress binary during `cypress/install` step:

```
version: 2.1

orbs:
  cypress: cypress-io/cypress@3

jobs:
  # Use cypress/default executor example
  default-executor cypress-install:
    executor: cypress/default
    steps:
      - cypress/install:
          post-install: CYPRESS_DOWNLOAD_MIRROR=https://cy-cdn.currents.dev npx cypress install --force
      - persist_to_workspace:
          root: ~/
          paths:
            - .cache/Cypress
            - project

  default-executor cypress-run:
    executor: cypress/default
    parallelism: 3
    steps:
      - attach_workspace:
          at: ~/
      - cypress/run-tests:
          cypress-command: npx cypress-cloud run --parallel --record --key $CURRENTS_RECORD_KEY

workflows:
  with-orbs default-executor:
    jobs:
      - default-executor cypress-install
      - default-executor cypress-run:
          context: currents
          requires:
            - default-executor cypress-install
```

#### Using custom executor with pre-installed Cypress App

The configuration below uses the [custom executor](https://circleci.com/docs/executor-intro/) with pre-installed Cypress App.

```
version: 2.1

orbs:
  cypress: cypress-io/cypress@3

executors:
  # define custom executors
  currents-executor:
    docker:
      - image: currentsdev/cypress-included:12.17.4

jobs:
  # Use currentsdev executor with pre-installed Cypress binary
  custom-executor cypress-install:
    executor: currents-executor
    steps:
      - cypress/install
      - persist_to_workspace:
          root: ~/
          paths:
            - project

  custom-executor cypress-run:
    executor: currents-executor
    parallelism: 3
    steps:
      - attach_workspace:
          at: ~/
      - cypress/run-tests:
          cypress-command: npx cypress-cloud run --parallel --record --key $CURRENTS_RECORD_KEY

workflows:
  with-orbs custom-executor:
    jobs:
      - custom-executor cypress-run:
          context: currents
```

#### Use Docker image with pre-installed Cypress

CircleCI configuration that uses Docker image with pre-installed cypress app. Refer to the [documentation](https://currents.dev/readme/integration-with-cypress/alternative-cypress-binaries) for the list of supported binaries and versions.


# Cypress - Bitbucket Pipelines

Running Cypress tests in parallel on Bitbucket Pipelines and Currents dashboard

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

[https://bitbucket.org/currents-org/currents-cypress-example](https://bitbucket.org/currents-org/currents-cypress-example/src/master/)
{% endhint %}

The example [config file](https://bitbucket.org/currents-org/currents-cypress-example/src/2e36527ccf01c9135dd51afaf620e7f930571dd9/bitbucket-pipelines.yml):

* uses a [docker image](https://hub.docker.com/r/currentsdev/cypress-included) with a pre-installed [alternative Cypress test runner](https://currents.dev/readme/integration-with-cypress/alternative-cypress-binaries) that allows using alternative orchestration services like Sorry Cypress and Currents.
* runs 3 containers with cypress tests in parallel using [`cypress-cloud`](https://github.com/currents-dev/cypress-cloud) integration package and the command below:

```
npx cypress-cloud --key $CURRENTS_RECORD_KEY --parallel
```

### Setup <a href="#markdown-header-setup" id="markdown-header-setup"></a>

* Create an account at <https://app.currents.dev>
* Get your **Record Key** and set [Secure Bitbucket Pipeline variable](https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/#Secured-variables) `CURRENTS_RECORD_KEY`
* Get your **Project ID** and update the contents of `currents.config.js`
* Follow the install instructions for [`cypress-cloud`](https://github.com/currents-dev/cypress-cloud) package
* Use CLI arguments to customize your cypress-cloud runs, e.g.: `npx cypress-cloud run --parallel --record --key <your currents.dev key> --group groupA`
* Note: Currents will automatically detect CI Build ID for Bitbucket Pipeline execution. Read the [guide](https://currents.dev/readme/guides/ci-build-id) for more advanced use cases.
* Note: Refer to the recent [Pipeline executions](https://bitbucket.org/currents-org/currents-cypress-example/pipelines/results/page/1) to see the setup in action

### Adding Bitbucket status check <a href="#markdown-header-adding-bitbucket-status-check" id="markdown-header-adding-bitbucket-status-check"></a>

[Currents integration with Bitbucket](https://currents.dev/readme/integrations/bitbucket) posts runs progress and outcome for every Bitbucket Pipeline invocation:

![](https://bytebucket.org/currents-org/currents-cypress-example/raw/2e36527ccf01c9135dd51afaf620e7f930571dd9/images/integration.png)

### Using Alternative Cypress Binaries <a href="#markdown-header-using-alternative-cypress-binaries" id="markdown-header-using-alternative-cypress-binaries"></a>

Currents team is maintaining an alternative version of the MIT-licensed Cypress test runner, compatible in features and open for using with recording services like Sorry Cypress and Currents.

See [Alternative Cypress Binaries](https://docs.currents.dev/getting-started/other-frameworks/cypress/integrating-with-cypress/alternative-cypress-binaries).


# Cypress - Azure DevOps

Running Cypress test in parallel on Azure DevOps and Currents Dashboard

This guide will help you to run Cypress tests in parallel using Azure DevOps and Currents Dashboard. The example showcases using 3 Azure DevOps containers for parallelizing the execution using Currents as an orchestration and reporting service.

{% hint style="info" %}
TLDR; Check out the example Azure DevOps pipeline [configuration file](https://github.com/currents-dev/currents-examples/blob/main/cypress/azure-devops/azure-pipelines.yml)
{% endhint %}

* Connect a new/existing pipeline to a repository containing your Cypress tests
* Make sure that your `cypress.config.js` file has the correct `projectId`. You can fetch the `projectId` by navigating to <https://app.currents.dev> and then **Project Name > Manage Project**
* Make sure that both `cypress` and [cypress-cloud](https://docs.currents.dev/resources/reporters/cypress-cloud) are listed in your `package.json` as dependencies
* Create or modify an existing [Variable Group](https://learn.microsoft.com/en-us/azure/devops/pipelines/library/variable-groups?view=azure-devops\&tabs=yaml), and add a new secret variable called `CURRENTS_SECRET`. You can grab the secret key at **Currents Dashboard > Org Name (Header Menu) > Record Keys**
* Modify your `azure-pipelines.yml` file and use [this file](https://github.com/currents-dev/currents-examples/blob/main/cypress/azure-devops/azure-pipelines.yml) as a reference.

```yaml
jobs:
  - job: Cypress_e2e_tests
    pool:
      vmImage: "ubuntu-latest"
    # Use 3 containers for parallel execution, use 
    strategy:
      parallel: 3
    # Fetch the secrets from Variable Group names "Currents"
    variables:
      - group: Currents
    steps:
      # Use Node@16 container
      - task: NodeTool@0
        inputs:
          versionSpec: "16.x"
          displayName: "Install Node.js"

      # Speed up the execution by caching the dependencies
      - task: CacheBeta@1
        inputs:
          key: npm | $(Agent.OS) | package-lock.json
          path: /home/vsts/.npm
          restoreKeys: npm | $(Agent.OS) | package-lock.json
        displayName: Cache NPM packages

      # cache cypress binary, which is installed at a different location
      - task: CacheBeta@1
        inputs:
          key: cypress | $(Agent.OS) | package-lock.json
          path: /home/vsts/.cache/Cypress
          restoreKeys: cypress | $(Agent.OS) | package-lock.json
        displayName: Cache Cypress binary

      # Install Node dependencies
      - script: npm ci
        displayName: "Install NPM dependencies"

      # Grab 
      # - CURRENTS_PROJECT_ID
      # - CURRENTS_RECORD_KEY
      # at https://app.currents.dev 
      #
      # Read more about CI Build ID:
      # https://currents.dev/readme/guides/cypress-ci-build-id

      # Note the use of `currents` command
      - script: |
          npx cypress-cloud run --record --parallel --key $CURRENTS_RECORD_KEY --ci-build-id $BUILD_BUILDNUMBER
        displayName: "Run Currents tests"
        env:
          CURRENTS_RECORD_KEY: $(CURRENTS_SECRET)
```

Pipeline executions will be orchestrated via the Currents Dashboard, and execution results and artifacts will be automatically uploaded as well.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FkVPkJu2y64rLdfKpnarl%2FAzure-Cypress%20example.png?alt=media&amp;token=7686cb26-72b2-4ccc-ba2b-aea216ff5e2c" alt=""><figcaption><p>Running Cypress Tests in Azure DevOps Pipeline</p></figcaption></figure>

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2F47M8Xncr9nWyTHzy6gc7%2Fcypress-azure-devops%402x.png?alt=media&amp;token=09805673-02c0-484b-8a42-295a8df7aa3a" alt=""><figcaption><p>Running Cypress Tests in Azure DevOps Pipeline</p></figcaption></figure>


# Cypress - AWS Code Build

Running Cypress in parallel on AWS CodeBuild

{% 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/cypress/aws-codebuild)
{% endhint %}

Executing Cypress tests in parallel on AWS CodeBuild can significantly reduce the overall run duration. AWS CodeBuild supports [Batched Build](https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build.html) in [matrix mode](https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build.html#batch_build_matrix) for launching several workers in parallel.

Those workers will use Currents as an orchestration service - each worker will run a subset of spec files and report the results to the cloud dashboard for convenient reporting and troubleshooting.

### Prerequisites

To enable parallel runs, please make sure:

* you have privileged access to your AWS Account
* you have an AWS CodeBuild project created with the batched configuration enabled

### Configuration Steps

The first step is to create a `buildspec.yml` file in the root directory of your application's source code repository. This file defines the build and test steps for your application.

In the `buildspec.yml` file, you need to create multiple workers that will run your Cypress tests in parallel by setting the desired number of workers. See an example with 3 workers below:

```yaml
## buildspec.yml
version: 0.2

batch:
  fast-fail: false
  build-matrix:
    dynamic:
      buildspec:
        - buildspec.yml
      env:
        variables:
          WORKERS:
            - 1
            - 2
            - 3

  phases:
    install:
      runtime-versions:
        nodejs: latest
      commands:
        # Set COMMIT_INFO variables to send Git details to Currents
        - export COMMIT_INFO_BRANCH="$(git rev-parse HEAD | xargs git name-rev |
          cut -d' ' -f2 | sed 's/remotes\/origin\///g')"
        - export COMMIT_INFO_MESSAGE="$(git log -1 --pretty=%B)"
        - export COMMIT_INFO_EMAIL="$(git log -1 --pretty=%ae)"
        - export COMMIT_INFO_AUTHOR="$(git log -1 --pretty=%an)"
        - export COMMIT_INFO_SHA="$(git log -1 --pretty=%H)"
        - export COMMIT_INFO_REMOTE="$(git config --get remote.origin.url)"
        - npm ci
    build:
      commands:
        - npx cypress-cloud run --record --parallel --ci-build-id $CODEBUILD_INITIATOR
```

You must also include the necessary commands to install Cypress, configure parallel execution, and run your tests.

By distributing tests to each worker, Currents enables faster execution of Cypress tests on AWS CodeBuild. This parallel execution ensures quicker feedback from your browser test suite while leveraging intelligent optimizations to minimize the overall runtime.

Additionally, Currents captures screenshots and videos during the test execution, facilitating troubleshooting efforts.

### Example: Cypress Tests in parallel on AWS CodeBuild

Please refer to [example repository](https://github.com/currents-dev/currents-examples/tree/main/cypress/aws-codebuild) that demonstrates how to set up AWS Code Build for running cypress tests in parallel using [Currents](https://currents.dev) service.

The example [config file](https://github.com/currents-dev/currents-examples/blob/main/cypress/aws-codebuild/buildspec.yml):

* uses 3 workers in [matrix mode](https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build.html#batch_build_matrix).
* is designed to be executed within a [batch build](https://docs.aws.amazon.com/codebuild/latest/userguide/batch-build.html).

Note:

* The example uses [CODEBUILD\_INITIATOR](https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html) as a [CI Build ID](https://currents.dev/readme/guides/cypress-ci-build-id). When testing interactively, the CODEBUILD\_INITIATOR will be set to the username of the build initiator. When running a batched build, the variable will have the batch build id. Read more about [CI Build ID](https://docs.currents.dev/guides/parallelization-guide/ci-build-id)
* get your record key from [Currents.dev](https://app.currents.dev/) and set [AWS CodeBuild Environment Variable](https://docs.aws.amazon.com/codebuild/latest/userguide/change-project-console.html#change-project-console-environment) variable `CURRENTS_RECORD_KEY`. Read more about [Record Key](https://docs.currents.dev/guides/record-key)
* set the `projectId` in `currents.config.js` - obtain the project id from [Currents.dev](https://app.currents.dev/)
* use CLI arguments to customize your cypress-cloud runs, e.g.: `npx cypress-cloud run --parallel --record --key <your currents.dev key> --group groupA`


# Cypress - NX

Running Cypress tests with NX

{% hint style="info" %}
The instructions below apply to **@currents/nx 2.0.0+**
{% endhint %}

### Running cypress tests in NX project with Currents

[Nx](https://github.com/nrwl/nx) is a build system with monorepo support and powerful integrations. You can run cypress tests on Currents using [`@currents/nx` plugin](https://www.npmjs.com/package/@currents/nx) and defining a few configuration options.

### Example

See <https://github.com/currents-dev/currents-nx> for an example installation and configuration

### Setting up cypress with NX

First, install `@currents/nx` npm package.

```sh
npm i --save-dev @currents/nx cypress-cloud
# install cypress if needed
npm i --save-dev cypress
```

Add `currents` target to your project configuration.

```json
{
  "targets": {
    "currents": {
      "executor": "@currents/nx:currents",
      "options": {
        "record": true,
        "parallel": true,
        "cypressConfig": "apps/app-e2e/cypres.config.ts",
        "devServerTarget": "my-react-app:serve",
        "testingType": "e2e"
      }
    }
  }
}

```

Create a new configuration file: `currents.config.js` next to `cypress.config.{jt}s`

```javascript
// currents.config.js
module.exports = {
  // Set the `projected` and the record key obtained from https://app.currents.dev or your self-hosted instance of Sorry Cypress
  projectId: 'IfERfK',
  // Sorry Cypress users - set the director service URL
  cloudServiceUrl: 'https://cy.currents.dev',
};
```

Add `cypress-cloud/plugin` to `cypress.config.{js|ts|mjs}`

```typescript
import { nxE2EPreset } from '@nrwl/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';
import cloudPlugin from 'cypress-cloud/plugin';

export default defineConfig({
  e2e: {
    ...nxE2EPreset(__dirname, {
      bundler: 'vite',
    }),
    specPattern: './src/**/*.cy.ts',
    setupNodeEvents(on, config) {
      return cloudPlugin(on, config);
    },
  },
});
```

### Usage

```
npx nx run web-e2e:currents --key <recordKey> --ci-build-id hello-currents-nx
```

* Update your `currents.config.js` file with `projectId` obtained at [https://app.currents.dev](https://app.currents.dev/)
* Use the record key obtained at [https://app.currents.dev](https://app.currents.dev/)
* Learn more about [CI Build ID](https://docs.currents.dev/guides/parallelization-guide/ci-build-id)


# Troubleshooting Cypress

Troubleshooting Currents integration with Cypress

{% hint style="warning" %}
**We are suspending our support of Cypress test runner version 13+**

We will continue to support [prior versions](https://docs.currents.dev/getting-started/other-frameworks/cypress/integrating-with-cypress/alternative-cypress-binaries) of Cypress.

[Read more](https://currents.dev/posts/v13-blocking)
{% endhint %}

If you are experiencing issues with using `@currents/cli` or `cypress-cloud`, please submit a [support request](https://docs.currents.dev/resources/support) either via in-app support chat or on GitHub:

* [@currents/cli GitHub Issues](https://github.com/currents-dev/cli/issues)
* [cypress-cloud GitHub Issues](https://github.com/currents-dev/cypress-cloud/issues)

Please collect the following information to help us effectively debug the problem:

* The associated dashboard run URL.
* Screenshots, if applicable.
* The exact command used to run `currents` or `cypress-cloud`.
* Configuration files (`cypress.config.{jt}s` and `currents.config.js`).
* CI environment information (use the command below):

```bash
npx envinfo --system --binaries --browsers --npmPackages --duplicates --npmGlobalPackages
```

* Activate debug mode and collect the logs.

{% hint style="info" %}
Please capture and share the **whole** debug log - that will help the support person identify the root cause faster
{% endhint %}

### Enabling `DEBUG` mode for `cypress-cloud@1.9.0+`

Starting from version 1.9.0 `cypress-cloud` provides a CLI flag for activating the debug mode.

```
npx cypress-cloud run ... --cloud-debug
```

You can specify the scope of debug messages printed:

* `true | all` shows all debug messages.
* `cypress` activates debug mode for cypress only.
* `currents` activates the debug mode for currents only.
* `commit-info` activates the debug mode for git commit info only.

### Enabling DEBUG mode for `@currents/cli` and `cypress-cloud < 1.9.0`

{% tabs %}
{% tab title="cypress-cloud" %}

```
# on Linux
DEBUG=currents:*,cypress:* npx cypress-cloud run ...

# on Windows
cmd /V /C "set DEBUG=currents:*,cypress:*&& npx cypress-cloud run ..."
```

{% endtab %}

{% tab title="@currents/cli" %}

```
# on Linux
DEBUG=cy2*,cypress:* npx currents run ...

# on Windows
cmd /V /C "set DEBUG=cy2*,cypress:*&& npx currents run ..."
```

{% endtab %}
{% endtabs %}


# Overview

Give AI agents your Playwright results from CI to fix tests and prove changes, and have agents record screenshots, video and traces of their own work

An AI agent that works on your app needs to see what the app did, not only an error message. Currents gives the agent that data, and gives you links to check the agent's work.

If a CI test covers the change, start with [Agentic testing](https://docs.currents.dev/ai/agentic-testing): the agent works from the runs Currents already recorded, with their errors, steps, console and network logs, screenshots, videos, traces and history. If no test covers it, start with [Agent evidence](https://docs.currents.dev/ai/agent-evidence): the agent records what it did as a [session](https://docs.currents.dev/ai/reference/sessions), and gives you one link to review it.

Without an agent, the dashboard explains a failed test for you, and what any test checks: see [AI in the dashboard](https://docs.currents.dev/ai/ai-in-the-dashboard).

## Try it in two minutes

1. Connect your agent to the Currents MCP server. See [Connect your agent](https://docs.currents.dev/ai/connect).
2. Paste a prompt with a run from your project: "Tests are failing in CI. Get the details for run `<runId>` and fix the failures." The run ID is in the run's URL in the dashboard, after `/run/`.
3. The agent reads the failure from Currents, fixes the cause, and runs the test again. See it in [Fix failing CI tests](https://docs.currents.dev/ai/agentic-testing/fix-failing-tests#example-an-agent-fixes-a-failed-run).

## What do you need?

| You want to                                                                  | Do you have a test for it? | Read                                                                                          |
| ---------------------------------------------------------------------------- | -------------------------- | --------------------------------------------------------------------------------------------- |
| Fix a failing test, with its full failure context and history                | Yes                        | [Fix failing CI tests](https://docs.currents.dev/ai/agentic-testing/fix-failing-tests)        |
| Prove a change works, from the CI runs before and after                      | Yes                        | [Prove a change with CI tests](https://docs.currents.dev/ai/agentic-testing/prove-a-change)   |
| Share the recording of a CI run with a colleague or an agent                 | Yes                        | [Share a CI run](https://docs.currents.dev/ai/agentic-testing/share-a-run)                    |
| Prove a change works, with a recording of the browser before and after       | No                         | [Record a bug and its fix](https://docs.currents.dev/ai/agent-evidence/bug-and-fix)           |
| Keep the logs and files of a task that is not testing                        | No                         | [Record any agent task](https://docs.currents.dev/ai/agent-evidence/any-agent-task)           |
| Let an agent read a Playwright trace in small steps                          | Either                     | [Explore a trace](https://docs.currents.dev/ai/agentic-artifacts/explore-a-trace)             |
| Post what Currents recorded on a pull request, in Slack or on a Linear issue | Either                     | [Post to GitHub, Slack, Linear](https://docs.currents.dev/ai/agentic-artifacts/post-evidence) |
| Give the agent the steps for one task, so the prompt stays short             | Either                     | [Agent skills](https://docs.currents.dev/ai/agent-skills)                                     |
| Find the flakiest and slowest tests, and when a test started failing         | Either                     | [Connect your agent](https://docs.currents.dev/ai/connect#try-it), then ask                   |
| Look up links, sessions, the trace API or MCP tools                          | Either                     | [Reference](https://docs.currents.dev/ai/reference)                                           |

Agents connect in Claude Code, Cursor, Claude, Codex, ChatGPT, your editor, or any other MCP client. See [Connect your agent](https://docs.currents.dev/ai/connect).


# AI in the dashboard

AI features built into the Currents dashboard: the likely cause of a failed test, and a plain explanation of what any test checks

Use these pages to get an AI answer about a test right in the dashboard, without connecting an agent. Currents sends the test's recorded data to an AI model and shows the answer in the test's **Insights** section.

| You want to                                      | Read                                                                                        |
| ------------------------------------------------ | ------------------------------------------------------------------------------------------- |
| Find out why a test failed, with suggested fixes | [AI Failure Analysis](https://docs.currents.dev/ai/ai-in-the-dashboard/ai-failure-analysis) |
| See what a test does and what it checks          | [Explain this test](https://docs.currents.dev/ai/ai-in-the-dashboard/explain-this-test)     |

Both need the **AI assistance** setting. An organization admin turns it on once, in the organization settings under **AI and data**. See [Turn on AI Failure Analysis](https://docs.currents.dev/ai/ai-in-the-dashboard/ai-failure-analysis#turn-on-ai-failure-analysis).

To have an agent fix the failure in your code, see [Fix failing CI tests](https://docs.currents.dev/ai/agentic-testing/fix-failing-tests).


# AI Failure Analysis

AI Failure Analysis shows the likely cause of a failed test and suggested fixes in the Currents dashboard

AI Failure Analysis shows the likely cause of a failed test, with suggested fixes, next to the test's results in the dashboard. An AI model writes it from the data Currents recorded for the test, so you start from a diagnosis instead of reading the error, steps and logs yourself.

AI Failure Analysis is available on every plan. An organization admin turns it on once for the whole organization. The same setting turns on [Explain this test](https://docs.currents.dev/ai/ai-in-the-dashboard/explain-this-test).

## Turn on AI Failure Analysis

AI Failure Analysis sends test data to an AI provider, so it needs your organization's consent.

1. Open the organization settings and select **AI and data**.
2. Turn on **AI assistance**.

Only organization admins can change this setting. Members who open a test before it is on see a note that asks them to contact an admin.

Turning **AI assistance** off stops AI Failure Analysis for everyone in the organization. Requests that are in progress fail. See the [AI terms](https://currents.dev/ai-terms) for how Currents and its AI providers handle the data.

## See why a test failed

1. Open a run and select a failed test.
2. In **Insights**, expand **Likely cause of the failure**.

Currents sends the request when you expand the card, and lists what the model checks while it works. When it finishes, the card title changes to the likely cause, and the card shows:

* The category of the failure: Network Error, Element Interaction, Assertion Failure, Timeout, Configuration Error, Syntax Error, Environment Error, Flaky Test or Other. Hover the category to see what it means.
* The root cause.
* Suggested fixes, each with a confidence level, and code when a fix needs it.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-c0028acb4a69620d179f32e3c314ee7c619fe537%2Fai-failure-analysis-likely-cause.png?alt=media" alt="The Insights section of a failed test with Likely cause of the failure expanded: the card title states the cause, then an Assertion Failure category, the root cause, and two suggested fixes with confidence levels and a code snippet" width="720"><figcaption></figcaption></figure>

The card appears only for tests with a failed attempt. The analysis covers the failed attempt of the test you opened.

## What the model reads

The model works from the data Currents recorded for the test: the error and stack trace, the test steps, the console output and the commit. It does not read your repository.

When the failed attempt has a Playwright trace, the model also investigates the trace with read-only tools. It lists the actions, reads the network requests and response bodies around the failing step, and looks at the page snapshot and screenshots at the failure. The card lists each check while the model works. Credentials are removed from text before it reaches the model; screenshots are sent as images.

If the test has no trace, or the trace cannot be read in time, the model explains the failure from the error, steps and console output alone.

Each card shows when the result was generated and how long it took. Currents keeps the result, so the next person who opens the same test sees it without a new request. Copy a result to paste it into a pull request, an issue or an agent prompt.

## Ask your agent instead

To have an agent fix the failure in your code, connect it to Currents. The agent reads the same failure data, and also has your repository. See [Fix failing CI tests](https://docs.currents.dev/ai/agentic-testing/fix-failing-tests).


# Explain this test

Explain this test describes in plain words what a test does and what it checks, in the Currents dashboard

Explain this test describes in plain words what a test does and what it checks. An AI model writes it from what Currents recorded for the test: its title, spec file, steps and assertions. It does not read your repository. It helps when you review a failure in a test you did not write, or when the test name does not say enough.

Explain this test works on any test, passed or failed. It needs the **AI assistance** setting that also turns on [AI Failure Analysis](https://docs.currents.dev/ai/ai-in-the-dashboard/ai-failure-analysis#turn-on-ai-failure-analysis).

## Explain a test

1. Open a run and select any test.
2. In **Insights**, expand **Explain this test**.

The card shows a short summary of what the test verifies, what the test does step by step, and the checks it makes. When they are evident, it also lists the setup the test depends on and caveats such as retries.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-a5132e0e5018ba3b64ba09bb0167f6666a781954%2Fai-explain-this-test.png?alt=media" alt="The Insights section of a test with Explain this test expanded: a one-line summary of what the test verifies, then What it does as numbered steps and What it checks as a list" width="720"><figcaption></figcaption></figure>

Currents keeps the result, so the next person who opens the same test sees it without a new request. Copy it to paste into a pull request, an issue or an agent prompt.

To find out why a failed test failed, use [AI Failure Analysis](https://docs.currents.dev/ai/ai-in-the-dashboard/ai-failure-analysis).


# Agentic testing

AI agents working with your CI test runs in Currents: fix failing tests, prove a change with the tests that cover it, and share a run

Use these pages when a CI test covers the change. If no test covers it, see [Agent evidence](https://docs.currents.dev/ai/agent-evidence).

Your CI already reports each test run to Currents, with its errors, steps, screenshots, videos and traces. Connect an agent to the [Currents MCP server](https://docs.currents.dev/ai/connect), and it works from that recorded data instead of the CI log. The agent does not have to run the tests again to see what happened, and it gives you links to the files it used.

| You want to                                                       | Read                                                                                        |
| ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| Hand a failing CI test to an agent, with the full failure context | [Fix failing CI tests](https://docs.currents.dev/ai/agentic-testing/fix-failing-tests)      |
| Prove a change works with the CI tests that cover it              | [Prove a change with CI tests](https://docs.currents.dev/ai/agentic-testing/prove-a-change) |
| Share the recording of a CI run with a colleague or an agent      | [Share a CI run](https://docs.currents.dev/ai/agentic-testing/share-a-run)                  |


# Fix failing CI tests

Hand a failing test to an AI agent with the full failure context, from the dashboard, Slack, the GitHub run comment, your editor or the MCP server

When a test fails in CI, an agent usually starts from the CI log: an assertion message, a stack trace and a few hundred lines of output. The log does not show what was on the page, which request returned the wrong data, or whether the test failed the same way last week. So the agent guesses. Often it adds a wait, loosens the assertion or retries until the test passes, and the bug stays in the code.

Currents keeps everything about each failure and gives it to the agent in one call:

* The page at the moment of failure: its accessibility tree, screenshots, video and the Playwright trace
* Browser console and network requests around the error
* The test's history: whether it is flaky, and the branch and commit where it started to fail
* The other tests in the run that failed with the same error

With that context the agent finds the cause in the app or in the test, fixes it, and runs the test again to check the fix.

Your agent needs the Currents MCP server. See [Connect your agent](https://docs.currents.dev/ai/connect). Without the MCP server, give your agent a [Fix link](#share-a-fix-link) from the dashboard, Slack or a GitHub comment. Any agent that can open a URL reads the failure from it.

## Example: an agent fixes a failed run

In this recording, Claude Code is connected to the Currents MCP server and gets the prompt from the first row of the table below. It reads the failed run from Currents and finds that the app's new discount calculation takes the discount off twice. It fixes the calculation and runs the tests again. It also reports a flaky test that it found, and does not change it. The recording is sped up.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-9c519de6f6b1fc8b4fb2bd6ca8bc6d326cc836d1%2Fterminal-fix-ci.gif?alt=media" alt="A terminal: Claude Code gets the context of a failed CI run from Currents, reads the code, fixes the discount calculation, runs the Playwright tests ten times, and reports the cause, the fix, and a flaky cart test it did not change"><figcaption></figcaption></figure>

## Hand a failure to an agent

| Where you are                                                                            | What to use                                                                                                                                                                                                                                                                                                           |
| ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Your agent, connected to the [Currents MCP server](https://docs.currents.dev/ai/connect) | Ask: "Tests are failing in CI. Get the details for run `<runId>` and fix the failures."                                                                                                                                                                                                                               |
| The dashboard                                                                            | **Fix with AI** on a failed test, **Fix** on a run, or **Fix** in the right-click menu of a test                                                                                                                                                                                                                      |
| Slack                                                                                    | **Fix with AI** or **Fix all with AI** on a failure notification from the [Slack App](https://docs.currents.dev/resources/integrations/slack/slack-app#fix-with-ai)                                                                                                                                                   |
| A pull request                                                                           | The **Fix with AI** section of the [run comment](https://docs.currents.dev/resources/integrations/github/github-app#fix-with-ai) or an [inline comment](https://docs.currents.dev/resources/integrations/github/github-app#inline-comments-on-spec-files) on a failed run: a link for you and a prompt for your agent |
| VS Code or Cursor                                                                        | **Fix with agent** in the [IDE Extension](https://docs.currents.dev/ai/connect/ide-extension#fix-with-ai)                                                                                                                                                                                                             |

The run ID is in the run's URL in the dashboard, after `/run/`. You can also give the agent the run link, the pull request or the branch.

## Use the fix-failing-tests skill

The Currents MCP server gives the agent the `fix-failing-tests` skill, with the steps for this task. To make sure the agent uses it, name it in the prompt: "Use the Currents MCP fix-failing-tests skill". See [Currents MCP server skills](https://docs.currents.dev/ai/agent-skills/agent-skill-currents-mcp).

## Fix with AI in the dashboard

The **Fix with AI** menu on a failed test, and the **Fix** menu on a run, give these choices:

* Open the context in Claude, Claude Code, Codex, Conductor, Cursor, GitHub Copilot or Zed.
* **Copy as prompt**, to paste into any other agent, or **Download Markdown**.
* **Share failure context**, to create a Fix link.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2F2ydY9L9r3J82290MpglF%2FCleanShot%202026-07-22%20at%2016.39.43%402x.png?alt=media&amp;token=5faed615-7175-4d42-b113-b29bb04500a2" alt="The Fix with AI menu on a failed test, with the agents it can open the context in"><figcaption></figcaption></figure>

## Share a Fix link

A [Fix link](https://docs.currents.dev/ai/reference/share-links) is a public link to the failure context of a test or a run. It opens a page with the context and buttons to open it in each agent. Give the link to someone outside your organization, or to an agent that fetches URLs. Add `.md` to the end of the link, and the agent reads the context as Markdown, with no credentials.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FNl0gv487GtqHXpufhZVD%2Fimage.png?alt=media&amp;token=9324851a-0d2a-48be-97d7-e54adba1bac2" alt="The Shared failure context page with buttons for each agent, the context, and the Markdown link"><figcaption></figcaption></figure>

Slack and the GitHub comments create a Fix link for you. A Fix link lasts 1 day unless you pick 3 or 7 days, and shows the failure as it was when you shared it. See [Share links](https://docs.currents.dev/ai/reference/share-links) for who can open it and how to turn sharing off.

## What the context contains

For one failed test:

* The spec, test title, status, attempt and duration
* The repository, branch, pull request and commit
* The error message and stack trace
* The error-context snapshot: the page's accessibility tree at the moment of failure
* Browser console and network requests around the error
* The trace error analysis, where a Playwright trace exists
* The steps that led to the failure, stdout and stderr
* Links to traces, screenshots, videos and attachments
* The OS, browser and versions, and how the other attempts ended

For a whole run: the run status and counts, the specs that did not pass, and each failing test with its error and steps. It lists how many files each test has, not links to them. Share a single test to get everything about one failure.

Every context ends with the IDs of the project, run, and, for one test, the instance, test and attempt. An agent connected to the [MCP server](https://docs.currents.dev/ai/reference/mcp-server) uses them to fetch more, such as other attempts or the test's history.


# Prove a change with CI tests

Prove an AI agent's change works with the CI tests that cover it: before and after screenshots, videos and traces from the runs Currents already stores

When a test in CI covers the change, the evidence is already in Currents. You do not need to run anything again, record the screen or take screenshots by hand. Currents stored every file of each test that ran: screenshots, videos, traces and the attachments your tests add. The failing run is the before, and the run on the branch with the fix is the after. The agent finds both runs and shows what changed, with links anyone can open.

Your agent needs the Currents MCP server. See [Connect your agent](https://docs.currents.dev/ai/connect).

## Example: evidence from two CI runs

In this recording, Claude Code is connected to the Currents MCP server. The branch has two runs in Currents: a failed run before the fix and a passed run after it. The agent reads the trace of each run, takes the order total from the page in each trace, and writes a pull request comment with links to the traces and run reports. The recording is sped up.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-a7de49667aa71d911552651f82371f532970425c%2Fterminal-ci-evidence.gif?alt=media" alt="A terminal: Claude Code finds the failed and the passed run of the branch in Currents, creates trace API links, reads the trace summary and a page snapshot of each run, and writes a pull request comment: the total was $183.60 before the fix and $206.55 after it"><figcaption></figcaption></figure>

## Ask the agent

Name the skill in the prompt, so the agent follows its steps:

```
Fix the checkout total bug. Once CI has run on this branch, use the Currents
MCP collect-evidence skill to collect before and after evidence, and post it
as a comment on the pull request.
```

The `collect-evidence` skill comes with the Currents MCP server, so there is nothing to install. See [Currents MCP server skills](https://docs.currents.dev/ai/agent-skills/agent-skill-currents-mcp). The skill reads only runs that CI already finished. It does not wait for a run in progress.

A passing test keeps a trace only if Playwright is set to keep one. With `trace: 'retain-on-failure'`, the after has screenshots and attachments but no trace. To keep a trace for the after too, set `trace: 'on'` for the tests that prove the change.

## What counts as evidence

Any file a test produced is evidence:

* Screenshots, to compare the page before and after
* Videos of the test, for a flow with many steps
* Attachments your tests add with `testInfo.attach()`, such as an API response, computed values or a CLI output
* The Playwright trace: a summary of the steps, a filmstrip and the page's accessibility tree at each step. The agent reads it through the trace API; see [Explore a trace](https://docs.currents.dev/ai/agentic-artifacts/explore-a-trace).

A trace gives the agent the most to work with, but it is not required.

## Post the evidence on the pull request

Ask the agent to write the result up as a pull request comment: what changed, the before and after, and the links. A reviewer then sees the evidence and the code in one place.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-1dd96d4a30130cc471833d3f788a2724b05bb224%2Fgithub-comment-ci-evidence.png?alt=media" alt="A pull request comment: fixed in abd6f49, with the ApplyDiscount response before and after the fix, and links to the response and the trace of each run"><figcaption></figcaption></figure>

Currents does not post the comment. Give the agent a tool that can, such as the GitHub CLI or the Linear MCP server, and say where to post in the prompt. Every link is public until it expires; see [Share links](https://docs.currents.dev/ai/reference/share-links). For Slack and Linear, see [Post evidence to GitHub, Slack and Linear](https://docs.currents.dev/ai/agentic-artifacts/post-evidence).

## When no test covers the change

Have the agent record the browser before and after the fix instead. See [Record a bug and its fix](https://docs.currents.dev/ai/agent-evidence/bug-and-fix).

## Troubleshooting

| Symptom                                   | Fix                                                                                                                                                                                                          |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `No trace found for this test attempt`    | The attempt kept no trace. The agent can use the screenshots, videos and attachments, or set `trace: 'on'` for the tests that prove the change.                                                              |
| The agent reports an older run than yours | The run on the branch is still in progress. Ask again when CI finishes.                                                                                                                                      |
| A link or file returns `404`              | The link expired, or the file is past [data retention](https://docs.currents.dev/resources/data-privacy/data-retention). Passed tests keep their files for 7 days, so collect the before and after together. |


# Share a CI run

Share a recording of a CI run with a colleague or an agent: one link to every test, with its screenshots, videos, traces and other files

A [Shared Run](https://docs.currents.dev/ai/reference/share-links) is a public link to the recording of a CI run: every test, its attempts, errors, screenshots, videos, traces and other files. Send it to a colleague or give it to an agent instead of a summary or a screenshot. They do not need a Currents account, and they open the files themselves to investigate further.

## From the dashboard

1. Open the run.
2. Click **Share**, then **Share whole run**.
3. Pick how long the link lasts: 1, 3 or 7 days.
4. Click **Create link**, then copy it or click **Open page**.

## From an agent

Your agent needs the Currents MCP server, with permission to read results and to create share links. See [Connect your agent](https://docs.currents.dev/ai/connect). Then ask the agent to share a run, and name the run by its pull request or its run ID:

* "Create a Currents share link for the latest CI run of pull request #42."
* "Create a Currents share link for run 652399ec733d0ddc."

The run ID is in the run's URL in the dashboard, after `/run/`. The agent gets two links: the page for people, and its Markdown version for agents.

## From the CLI

Run [`currents run share`](https://docs.currents.dev/resources/reporters/currents-cmd/currents-run-share) with the run ID and an API key with write access. It prints the link and its Markdown version. The same command shares one spec file or one test of the run.

```bash
CURRENTS_API_KEY=<api-key> npx --package @currents/cmd@2 currents run share <run-id>
```

## What people see

* The project, start time, status counts, and the git branch, commit and pull request
* Each spec file and test with its status, and a link to the test in the dashboard
* For each attempt: its error, and links to its screenshots, videos, traces and other files
* For each failed or flaky test, a link to its full failure context

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-7d598eea6b5c1c218984dccd420bc504d94cb679%2Fshared-run-page.png?alt=media" alt="A Shared Run page: the run status counts, the branch and commit, the run attachments, and the Markdown link for agents at the bottom"><figcaption></figcaption></figure>

The page shows the run as it was when you created the link. It lists up to 2,000 tests, and leaves out passed tests first.

## What an agent sees

Add `.md` to the link to get the same run as Markdown. Give this link to an agent. It needs no Currents connection to read it.

The Markdown has a link to every file of every attempt, and the agent can open each one:

* Screenshots and videos
* Attachments your tests add, such as an error context or an API response
* The trace of each attempt, through a trace API link (labeled "explore trace")
* The full failure context of each failed or flaky test: steps, stdout, environment and files

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-4113a9ef177c4a0b92a3e9b157fd3e6480d5dc6f%2Fshared-run-markdown.png?alt=media" alt="The Markdown version of a Shared Run: the run ID, project and status counts, the branch and commit, then the failed test SAVE10 takes 10% off the total with links to its full context, screenshot, video, error context and trace, and the error: expected $206.55, received $183.60"><figcaption></figcaption></figure>

The trace API lets the agent read the trace in small steps: first a summary of the actions, then only the page, frame or network request it needs. See [Explore a trace](https://docs.currents.dev/ai/agentic-artifacts/explore-a-trace).

In this recording, Claude Code gets the Markdown link of a Shared Run. It reads the run, opens the trace summary of the failed test, then reads the page text and the screen at the failure:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-896ed0ce2cef035ad394657c1acebda98a98f9aa%2Fterminal-shared-run.gif?alt=media" alt="Claude Code fetches a Shared Run Markdown link with curl, then the trace digest, the page text and the frame at the failure of the test SAVE10 takes 10% off the total, and answers that the app takes the 10% discount off twice: the total is $183.60 instead of $206.55"><figcaption></figcaption></figure>

See [Share links](https://docs.currents.dev/ai/reference/share-links) for who can open the link and how to turn share links off.


# Agent evidence

Record screenshots, video, a Playwright trace and logs of what your AI agent did, and share them as one link: proof for a pull request, a bug report or a task that is not a test

Use agent evidence when no test covers what the agent did. When a CI test covers it, the CI runs are the evidence: see [Agentic testing](https://docs.currents.dev/ai/agentic-testing).

When an AI agent says "fixed" or "done", you usually get a summary and maybe a screenshot in the chat. To check the work, you run the branch yourself. With agent evidence, the agent records what it did in the browser or on the machine, and saves it to Currents: screenshots, video, the Playwright trace, page snapshots and logs. You get one link to all of it. A reviewer opens the link without a Currents login, and another agent can read the same link as text. Anyone with the link can open it, so share it only where you would post a public gist; see [Share links](https://docs.currents.dev/ai/reference/share-links).

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-17950732ae6f6b7eb7a1b7e6ebfaf0f4ae2c3636%2Fsession-failed.png?alt=media" alt="A recording of a failed checkout: its title, error, pull request, branch and commit, and its files with the screenshot open"><figcaption></figcaption></figure>

Currents keeps each recording as a session: a title, a passed or failed status, the commit, the pull request and the files. A session is not a test run, and it does not change your run lists, analytics or flakiness. The dashboard has no list of sessions: keep the link, or find sessions with the API. See [Sessions](https://docs.currents.dev/ai/reference/sessions).

## When to use it

| You want to                                                                         | Read                                                                                                 |
| ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| Show a bug, then show it fixed, on a pull request                                   | [Record a bug and its fix](https://docs.currents.dev/ai/agent-evidence/bug-and-fix)                  |
| Keep the logs and files of a task that is not testing                               | [Record any agent task](https://docs.currents.dev/ai/agent-evidence/any-agent-task)                  |
| Record a browser driven with Playwright MCP                                         | [Record with Playwright MCP](https://docs.currents.dev/ai/agent-evidence/bug-and-fix/playwright-mcp) |
| Record a browser driven with Playwright CLI                                         | [Record with Playwright CLI](https://docs.currents.dev/ai/agent-evidence/bug-and-fix/playwright-cli) |
| Keep the results of a Playwright Test or Vitest run that did not report to Currents | [Record local test results](https://docs.currents.dev/ai/agent-evidence/local-test-results)          |
| Record from an agent that cannot install the Currents CLI                           | [Record without the Currents CLI](https://docs.currents.dev/ai/agent-evidence/mcp-tools)             |

## Install the Currents CLI and set a key

* The Currents CLI, `@currents/cmd` 2.0 or later, in the project: `npm install --save-dev @currents/cmd`. Without it, `npx currents` runs an unrelated npm package that is also named `currents`.
* A [record key](https://docs.currents.dev/guides/record-key) in `CURRENTS_RECORD_KEY`, such as the one your CI already uses, or a Read & Write [API key](https://docs.currents.dev/dashboard/administration/api-keys) in `CURRENTS_API_KEY`.

## Record your first session

Three commands create a session, add files to it and share it:

```bash
npx currents session start --project-id <project-id> --title "Checkout total ignores coupons" --status failed
npx currents session attach before.png after.png
npx currents session share
```

`session attach` takes any files or folders. `session share` prints two links: a page for people and a Markdown version of the same page for agents. See [currents session](https://docs.currents.dev/resources/reporters/currents-cmd/currents-session) for all options.

To have an agent do it, give it a [skill](https://docs.currents.dev/ai/agent-skills) with the steps: an agent connected to the Currents MCP server has one, with nothing to install; an agent with only a shell needs `npx currents skill --install`.

## What people see

The page link opens the session: its title, status, error, tags, branch, commit and pull request, and its files. You can show the files as a gallery, a list, or a timeline in the order the agent recorded them.

You can open every file on the page:

* Screenshots and other images, side by side to compare before and after
* Videos, in a video player
* Playwright traces, in a trace player or in the Playwright Trace Viewer
* Page snapshots, the `page-*.yml` files that Playwright MCP and Playwright CLI save. The page shows each one as an accessibility tree, with what changed since the snapshot before it.
* Console logs, HAR files, JSON, Markdown, CSV and other text files, up to 512 KB each
* Any other file, as a download

Select a page snapshot on the timeline to see what changed, next to the screenshot taken at the same time:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-6e8ba33f5fc3b74301bc1f3288755fc8dc23c898%2Fsession-timeline-changes.png?alt=media" alt="The timeline with a page snapshot selected: the before and after screenshots side by side, and the changes: Applying… became Apply, the discount and the total changed"><figcaption></figcaption></figure>

The page always shows the current session. Files attached after you shared it appear too.

## What agents see

The Markdown link is the page link with `.md` at the end. An agent reads it without a Currents login. It holds:

* The title, status, tags, error, branch, commit and pull request
* A link to each file, with its caption
* For the first trace: a short text summary with each action and its time, page errors and console errors
* The accessibility tree of the page at the end of that trace

Each trace has a link to the [trace API](https://docs.currents.dev/ai/agentic-artifacts/explore-a-trace). The agent uses it to read one part of the trace at a time, such as the page text at one moment or the network requests, instead of downloading the whole trace.

## Share one file

Each file in a session has its own link, which works for as long as the session link. On the session page, open a file and select Copy link, or Copy markdown for a Markdown line: an embedded image for a screenshot, a link for any other file. Post one file in a pull request, an issue or a chat without the rest of the session.

## Example: an agent finds a bug from a session

The session "Lowercase discount code freezes checkout" holds a trace, a video, a console log, a screenshot and a page snapshot. Give an agent its Markdown link:

```
Checkout froze in this recorded session: https://s.crts.sh/ai/<slug>.md
Read it, then use its trace API links to read the page text right after the
Apply click and the network requests. Tell me the cause in 5 short lines.
```

The agent reads the session's Markdown link, then uses the trace API to read the page text right after the click and the network requests. It finds that the click handler throws an error on the lowercase code, so the button never resets. [Explore a trace](https://docs.currents.dev/ai/agentic-artifacts/explore-a-trace) walks through the same trace step by step.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-9d57bfb0013cd81cae61db10d437b7614d53ec16%2Fterminal-session-trace.gif?alt=media" alt="A terminal agent fetches a session&#x27;s Markdown link, then the page text after the Apply click and the network requests from the trace API, and answers that the lookup of the lowercase code save10 throws a TypeError at app.js:39, so Apply stays on Applying…"><figcaption></figcaption></figure>


# Record a bug and its fix

Have an AI agent record a bug and its fix in the browser, with screenshots, page snapshots and a Playwright trace, and post the before and after on the pull request as proof the change works

An agent fixed a bug that no test covers. To approve the fix, a reviewer needs to see the bug, then see it gone, without running the branch. Have the agent record the browser before the fix and after it, in one [session](https://docs.currents.dev/ai/agent-evidence), and post the [session link](https://docs.currents.dev/ai/reference/share-links) on the pull request. The session page puts the two screenshots side by side and lists what changed on the page.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-6e8ba33f5fc3b74301bc1f3288755fc8dc23c898%2Fsession-timeline-changes.png?alt=media" alt="A session with the before and after of a checkout fix: the two screenshots side by side, and the page changes: Applying… became Apply, the discount and the total changed"><figcaption></figcaption></figure>

When a CI test covers the bug, you do not need a recording: the failing run is the before and the passing run is the after. See [Prove a change with CI tests](https://docs.currents.dev/ai/agentic-testing/prove-a-change).

## What you need

* A [skill](https://docs.currents.dev/ai/agent-skills) that has the steps, so you do not have to describe them.
* A browser the agent can drive. There are two ways: [Playwright MCP](https://docs.currents.dev/ai/agent-evidence/bug-and-fix/playwright-mcp), an MCP server, or [Playwright CLI](https://docs.currents.dev/ai/agent-evidence/bug-and-fix/playwright-cli), shell commands. Each page has the setup.
* A tool that can post on the pull request, such as the GitHub CLI. Currents does not post the comment.

## Ask the agent

Name the skill in the prompt and say what to fix:

```
Use the Currents browser-evidence skill. Reproduce the checkout bug at
http://localhost:3000: entering save10 leaves Apply stuck on "Applying…".
Record it, fix it, record the fix, and post the session link on the pull
request.
```

The agent records the bug, fixes the code, records the same steps again, shares the session and replies with the link. Claude Code with this prompt, sped up:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-f5c295bc28dbb49f232fa332d991bd225052bd54%2Fterminal-bug-and-fix.gif?alt=media" alt="A terminal: Claude Code starts a session, records the checkout before the fix with playwright-cli, attaches it captioned before, edits app.js, records and attaches the after, shares the session, and replies with the cause, the fix and the session link"><figcaption></figcaption></figure>

## What the reviewer sees

The comment on the pull request has the before and after, and links to the session:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-3deeca8c135cc2e44298b3313535f537d3f96d4e%2Fgithub-comment-session-evidence.png?alt=media" alt="A pull request comment with the before and after screenshots side by side, links to each session page and trace digest, and the accessibility tree changes as a diff"><figcaption></figcaption></figure>

The session page has:

* The before and after screenshots, side by side or with a slider
* What changed on the page: elements added, removed, and text that changed
* The trace of each recording, with the clicks and requests
* The commit and the pull request the fix is on

To post the evidence in Slack or Linear, see [Post evidence to GitHub, Slack and Linear](https://docs.currents.dev/ai/agentic-artifacts/post-evidence).


# With Playwright MCP

Record what an agent did with Playwright MCP, with a trace, screenshots and page snapshots, and share it as a Currents session

[Playwright MCP](https://github.com/microsoft/playwright-mcp) is an MCP server that lets an agent drive a browser. When the agent also records a trace, screenshots and page snapshots, you can check what it did in the browser instead of trusting its summary. Save the recording to Currents as a [session](https://docs.currents.dev/ai/agent-evidence), and you get one link to all of it.

## What you need

* Playwright MCP with its tracing tools turned on, so the agent can record a trace. The `--caps=devtools` option turns them on. For Claude Code:

  ```bash
  claude mcp add playwright -- npx @playwright/mcp@latest --caps=devtools
  ```
* The Currents CLI and a key. See [Install the Currents CLI and set a key](https://docs.currents.dev/ai/agent-evidence#install-the-currents-cli-and-set-a-key).

## Ask the agent

```
Reproduce the checkout total bug at http://localhost:3000 with Playwright MCP.
Record it as a Currents session, fix the code, record it again, and post both
links on the pull request.
```

With a Currents [skill](https://docs.currents.dev/ai/agent-skills), the agent records and shares the session without more instructions. Claude Code recording the bug, sped up:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-34cdb79843797c3474fd74ac02afa6022a211313%2Fterminal-playwright-mcp.gif?alt=media" alt="A terminal: Claude Code empties the traces folder, starts a failed session, starts tracing, fills the discount code and clicks Apply with Playwright MCP, saves a screenshot and a page snapshot, stops tracing, attaches the files captioned before, and shares the session"><figcaption></figcaption></figure>

## What you get

A session with the before and after, in the Gallery view:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-e2bf1fdec7840dbdf109dbfc9a98a76a364ca3ba%2Fsession-gallery.png?alt=media" alt="A session gallery with the before and after screenshots, the before and after traces, the console log and the two page snapshots"><figcaption></figcaption></figure>

The trace opens in a trace player on the session page. A page snapshot is the page's accessibility tree, with its text. Two page snapshots show what changed, even when two screenshots look the same.


# With Playwright CLI

Record what an agent did with Playwright CLI, with a trace, video, screenshots and page snapshots, and share it as a Currents session

[Playwright CLI](https://www.npmjs.com/package/@playwright/cli) (`playwright-cli`) drives a browser from shell commands, so any agent with a shell can use it. When the agent records the browser while it works, you can check what it did: the screenshots, the video, the trace of every click and request, and the page text. Save the recording to Currents as a [session](https://docs.currents.dev/ai/agent-evidence), and you get one link to all of it.

## What you need

* Playwright CLI. See its [install steps](https://www.npmjs.com/package/@playwright/cli).
* The Currents CLI and a key. See [Install the Currents CLI and set a key](https://docs.currents.dev/ai/agent-evidence#install-the-currents-cli-and-set-a-key).

## Record a browser session

Start a Currents session, record with Playwright CLI, then attach the files and share the session:

```bash
npx currents session start --project-id <project-id> --title "Lowercase discount code applies 10% off" --status passed

playwright-cli open
playwright-cli tracing-start
playwright-cli video-start
playwright-cli goto http://localhost:3000/
playwright-cli snapshot
# ... fill, click and other commands
playwright-cli snapshot --filename=discount-applied-a11y.yml
playwright-cli screenshot --filename=discount-applied.png
playwright-cli video-stop
playwright-cli tracing-stop
playwright-cli close

npx currents session attach discount-applied.png discount-applied-a11y.yml .playwright-cli/traces
npx currents session share
```

* `snapshot` saves the page's accessibility tree, with its text, as a `.yml` file.
* `session attach` packs the `.playwright-cli/traces` folder into one trace. The video is also in `.playwright-cli`: attach it by name.
* Attach only the files you name. Do not attach the whole `.playwright-cli` folder: it holds the browser's storage state, with cookies, and anyone with the link could read it.
* Empty `.playwright-cli/traces` before each recording. Two recordings at once write to the same folder, and `session attach` would pack their traces together.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-61633d039dd5f596655ddfb602ac96cb4edc91d5%2Fterminal-playwright-cli.gif?alt=media" alt="A terminal running the commands above: currents session start, the playwright-cli commands and their output, currents session attach, and share, which prints the session link"><figcaption></figcaption></figure>

To have an agent do these steps, give it a Currents [skill](https://docs.currents.dev/ai/agent-skills). See [Record a bug and its fix](https://docs.currents.dev/ai/agent-evidence/bug-and-fix).

## What you get

The session page puts the screenshot, video, trace, page snapshot and console log on one timeline:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-f9667d0741f6b5ed00de58fae0ca758953b5baea%2Fsession-playwright-cli.png?alt=media" alt="A session recorded with Playwright CLI on the Timeline view: rows for screenshots, videos, traces, and text and logs, with the video open below"><figcaption></figcaption></figure>


# Record any agent task

Record the logs, output files and screenshots of any task an AI agent did, not only testing, and share them as one link that outlives the machine it ran on

An agent that runs on a remote machine, such as a cloud dev box, a sandbox or a CI job, leaves its results on that machine. When the machine goes away, so do the logs, the files it wrote and the screenshots it took. Have the agent save them to Currents as a [session](https://docs.currents.dev/ai/agent-evidence) at the end of the task. You get one link to review what the agent did, and the files stay after the machine is gone.

The task does not have to be a test. For example:

* An agent ran a data migration. The session holds the migration log, the row counts before and after, and its summary.
* An agent updated the dependencies of a service. The session holds the build output and the list of packages it changed.
* An agent checked a staging site after a deploy. The session holds the screenshots of each page and the console log.

## What you need

The Currents CLI and a key on the machine. See [Install the Currents CLI and set a key](https://docs.currents.dev/ai/agent-evidence#install-the-currents-cli-and-set-a-key). On a CI job, the agent can use the record key the job already has.

## Ask the agent

Add this to the agent's task, or to its instructions file:

```
When you finish, save your results as a Currents session in project
<project-id>: your log, every file you wrote, and a summary.md with what you
did and what you did not do. Use --status failed if the task did not finish.
Reply with the link.
```

The agent saves the files with `currents session start`, `attach` and `share`. These commands take any file or folder. For the options, see [currents session](https://docs.currents.dev/resources/reporters/currents-cmd/currents-session) or run `npx currents session --help`.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-7f556f5edb7189239d8a64bac653d363b7a8fffc%2Fterminal-agent-task.gif?alt=media" alt="A terminal: ls shows the task&#x27;s output folder, log and summary; currents session start, attach with the folder and two files, and share, which prints the session link and its Markdown link"><figcaption></figcaption></figure>

## What you get

The session page of the migration above, with the agent's summary open:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-bc831945a44b2f604fba63f0158195111e3e2a59%2Fsession-agent-task.png?alt=media" alt="A passed session titled Migrate order items to order_line_items on staging, with four files: skipped-orders.csv, migration.log, row-counts.json and summary.md, which is open and rendered with a table of row counts before and after"><figcaption></figcaption></figure>

The link opens without a Currents login for 1, 3 or 7 days. The files stay until you delete the session. See [Share links](https://docs.currents.dev/ai/reference/share-links).


# Record local test results

Share the traces, screenshots and videos of a Playwright Test or Vitest run that is not reported to Currents, as one session

Sometimes an agent writes a test only to check its change, runs it once, and does not keep it. The run is not reported to Currents, but its traces, screenshots and videos show that the change works. Attach them to a [session](https://docs.currents.dev/ai/agent-evidence), and the reviewer gets one link to the test results instead of a summary in the chat.

For tests that stay in your suite and run in CI, report them to Currents instead. See [Prove a change with CI tests](https://docs.currents.dev/ai/agentic-testing/prove-a-change).

## What you need

The Currents CLI and a key. See [Install the Currents CLI and set a key](https://docs.currents.dev/ai/agent-evidence#install-the-currents-cli-and-set-a-key).

## Playwright Test

Turn on what you want to keep for this run:

```ts
// playwright.config.ts
use: { trace: 'on', screenshot: 'on', video: 'on' },
```

Run the tests, then attach the whole `test-results` folder:

```bash
npx playwright test
npx currents session start --project-id <project-id> --title "Lowercase discount code" --status failed
npx currents session attach test-results
npx currents session share
```

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-396d4bb5ff43b0fa3f4abcebee966c35ccc5707f%2Fterminal-local-test-results.gif?alt=media" alt="A terminal: npx playwright test with one failed and one passed test, then currents session start, attach test-results, which lists the trace, screenshots, videos and error-context.md of each test, and share"><figcaption></figcaption></figure>

Playwright writes one subfolder per test in `test-results`, and `session attach` takes them all: the trace, screenshots, video and `error-context.md`, the page snapshot Playwright saves when a test fails. Each trace opens in the trace player. To show what ran, also attach the JSON report or the console output of the run.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-076108c27fe8c6e4b018d30be1651d2e67314ca1%2Fsession-test-results.png?alt=media" alt="A failed session with the test error, and the files of two tests named by their test-results folder: screenshots, videos, traces, error-context.md and results.json. The failed test screenshot shows Apply stuck on Applying"><figcaption></figcaption></figure>

<details>

<summary>Vitest</summary>

In Vitest browser mode with the Playwright provider, set `browser.trace: 'on'`. Vitest writes traces to a `__traces__` folder and failure screenshots to a `__screenshots__` folder, next to each test file. Start a session as for Playwright Test, then attach those folders and the output of the run:

```bash
npx vitest run > vitest-output.log
npx currents session attach src/checkout/__traces__ src/checkout/__screenshots__ vitest-output.log
npx currents session share
```

Unit tests produce no browser files. Attach the output, the JSON report or the coverage summary, so the reader sees what ran and what passed.

</details>


# Record without the Currents CLI

Record a session with the Currents MCP tools when the agent cannot run the currents command

Some agents cannot install npm packages, so they cannot run the Currents CLI. If the agent is connected to the [Currents MCP server](https://docs.currents.dev/ai/connect) and has a shell, it can still save its screenshots, traces and logs as a [session](https://docs.currents.dev/ai/agent-evidence), and give you one link to them. An agent with no shell cannot upload files: it can only report the screenshots and page snapshots it has, and say that it did not record a session.

## What you need

* The agent connected to the Currents MCP server, with permission to write runs (`runs:write`) and to create share links (`shares:write`). You approve these permissions when you connect the agent. See [Connect your agent](https://docs.currents.dev/ai/connect).
* A shell, to upload the files, for example with `curl`.

## Ask the agent

```
Use the Currents browser-evidence skill. Record the checkout bug at
http://localhost:3000 as a Currents session and give me the link.
```

The skill has the steps: the agent creates the session through the MCP server, uploads its files from the shell, and creates the share link.

Claude Code with only the Currents MCP server and a shell, sped up:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-f7b50c1cd92ef8573dad8327c5bde8da429ff077%2Fterminal-mcp-tools.gif?alt=media" alt="A terminal: Claude Code calls currents-create-session with four files, uploads each file with curl, calls currents-create-share-link, and replies with the session and its share page link"><figcaption></figcaption></figure>

## What you get

The Markdown version lists the session, its commit and pull request, and a link to each file. For a trace, it has a short text summary with each action, page errors and console errors. Another agent can check the work from it without opening the files.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-86a3e0aa3ba439b46a8ce4c1bd61d6fcceb98bcf%2Fsession-markdown.png?alt=media" alt="The Markdown version of a session: status, git details, each attachment with its link and caption, and links to the trace digest, frames, snapshots and failed requests"><figcaption></figcaption></figure>


# Agentic artifacts

Let agents read Playwright traces in small steps, and post screenshots, traces and recordings from Currents to GitHub, Slack and Linear

These pages work for everything Currents recorded: CI runs from [Agentic testing](https://docs.currents.dev/ai/agentic-testing) and sessions from [Agent evidence](https://docs.currents.dev/ai/agent-evidence).

A screenshot shows what the page looked like. A Playwright trace shows why: every action, the page after each action, and every network request. Currents gives each trace a link that an agent reads one small part at a time, and that gives people images to put in a pull request or a chat.

| You want to                                                                             | Read                                                                                          |
| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| Let an agent find the cause of a failure in a trace, without loading the whole file     | [Explore a trace](https://docs.currents.dev/ai/agentic-artifacts/explore-a-trace)             |
| Put screenshots, traces and recordings on a pull request, in Slack or on a Linear issue | [Post to GitHub, Slack, Linear](https://docs.currents.dev/ai/agentic-artifacts/post-evidence) |


# Explore a trace

Give an agent a trace API link, and let it read a Playwright trace in small steps instead of loading the whole file. Get images of the trace for people: filmstrip, animation, frames and the page at th

This page works for traces from CI tests and from sessions an agent recorded. A Playwright trace records everything a test or a [browser session](https://docs.currents.dev/ai/agent-evidence) did: every action, the page after each action, every network request, and a recording of the screen. A screenshot shows what the page looked like. The trace shows why.

A trace file is a zip of several megabytes, too large for an agent to read at once, and people need the Playwright trace viewer to open it. The Currents trace API solves both:

* An agent reads the trace one small part at a time. It starts with a summary of the actions and the failure, then asks only for the page, request or screen that the summary points to.
* People get images from the same API: a filmstrip, an animation, the screen at the failure, or the page as it looked then. Put them in a pull request or an issue. See [Post evidence to GitHub, Slack and Linear](https://docs.currents.dev/ai/agentic-artifacts/post-evidence).

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-7dfe3993f75881479b2045d5fd86f257f6eee6be%2Ftrace-link-flow.svg?alt=media" alt="Fix links, Shared Runs, the GitHub run comment, session pages, the MCP tool and the REST API all give a t.crts.sh trace API link. The agent reads its summary first, then only the snapshots, requests or frames it needs."><figcaption><p>Where trace API links come from, and how an agent reads one</p></figcaption></figure>

The trace can come from Playwright Test, Playwright MCP, Playwright CLI, or Vitest browser mode with the Playwright provider (`browser.trace: 'on'`, which writes to `__traces__` next to each test file). Attach a local trace to a [session](https://docs.currents.dev/ai/agent-evidence) to get a link for it. Anyone with the link can open it without a Currents login.

## Get a trace API link

| You have                                          | Where the trace API link is                                                                                                                     | It lasts                                                                            |
| ------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| A failed test in CI                               | The [Fix link](https://docs.currents.dev/ai/agentic-testing/fix-failing-tests) of the test or run: an **explore trace** link next to each trace | As long as the Fix link                                                             |
| A failed test, and an agent connected to Currents | The failure context the agent gets from the Currents MCP server: the same **explore trace** link                                                | 12 hours                                                                            |
| A CI run you shared                               | The [Shared Run](https://docs.currents.dev/ai/agentic-testing/share-a-run) page and its Markdown version: a link for each attempt's trace       | As long as the Shared Run                                                           |
| A pull request with a failed run                  | The GitHub run comment: a trace API link for each failed test                                                                                   | As long as the comment's Fix link                                                   |
| A session                                         | The session page: **Explore with agent** on a trace. The session's Markdown version lists the link too.                                         | As long as the [Shared Session](https://docs.currents.dev/ai/reference/share-links) |
| Any test or session trace, from an agent          | Ask an agent connected to the Currents MCP server for a trace API link                                                                          | 24 hours, or up to 7 days                                                           |
| Any test or session trace, from a script          | The REST API: see [Trace API](https://docs.currents.dev/ai/reference/trace-api#get-a-trace-api-link-from-a-script)                              | 24 hours, or up to 7 days                                                           |

For what each kind of link opens and who can open it, see [Share links](https://docs.currents.dev/ai/reference/share-links).

On a session page, **Explore with agent** on a trace copies a prompt with the trace API link, opens the trace summary, or opens the prompt in your coding tool:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-fba1170289bea84e52633168f26adb1eef7d33f5%2Fsession-explore-with-agent.png?alt=media" alt="A trace on a session page with the Explore with agent menu open: Copy prompt, Open trace index, and Open in Claude, Claude Code, Codex, Conductor, Cursor, GitHub Copilot or Zed"><figcaption><p>Explore with agent on a trace in a session</p></figcaption></figure>

## Ask the agent

Paste the Fix link of a failed test, then:

```
Read the trace of the failed attempt: the summary first, then the page at the
failure. Tell me what the page showed when the test failed, before you change
the code.
```

For a session where an API response looks wrong:

```
Open the trace API link in this session. Find the request whose body contains
ApplyDiscount, and compare its response with the total the page shows.
```

To show the failure to people:

```
Get a trace API link for the failed attempt. Add its filmstrip up to the failure
and the frame at the failure to the pull request comment.
```

## Example: a checkout that freezes

A session recorded a checkout where the discount code `save10` leaves the **Apply** button stuck. The agent got the trace API link from the session page with **Explore with agent**. Times are milliseconds from the start of the trace.

1. The summary, `/digest`, lists the actions. No action failed, but the page threw a `TypeError` 33 ms after the click on **Apply**. About 450 tokens.
2. The network requests, `/requests`: all 3 returned 200 before the click, so the server is not the cause. About 300 tokens.
3. The page text right after the error, `/snapshots/2464?format=text`: the input holds `save10` in lowercase, the button reads `Applying…`, and the total is still `$229.50`. About 100 tokens.
4. The screen at the end, `/frames/4024`: the button is still stuck. An image of about 750 tokens.

The agent used about 1,600 tokens. Every file in the trace together is about 20,000 tokens.

## What the agent reads

The agent asks the trace API for one part at a time: the summary, the page text, the accessibility tree, the HTML, the network requests and their bodies, or the files in the trace. [Trace API](https://docs.currents.dev/ai/reference/trace-api) lists each route, with real output from a failed test.

An agent in a terminal does this with `curl`. It reads each answer and picks the next call from it, until it can answer. Here it reads the trace of the checkout example above:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-3c2bb39ad6f38fbc4506ab85aecc04dd0ddf0fcd%2Ftrace-api-calls.svg?alt=media" alt="Animation. A terminal agent and the trace API exchange four calls in a loop. The agent asks for /digest and learns no action failed and a TypeError came 33 ms after the click on Apply. It asks for /requests and learns all 3 requests returned 200 before the click. It asks for /snapshots/2464 and sees the input holds lowercase save10, the button reads Applying… and the total is $229.50. It asks for /frames/4024 and gets an image of the button still stuck. It answers that save10 is not a key in DISCOUNT_CODES and the error stops the handler before it resets the button. It used about 1,600 tokens, of about 20,000 for the whole trace."><figcaption><p>An agent finds the cause of the stuck checkout in four calls to the trace API</p></figcaption></figure>

## Available formats

The trace API returns each part of the trace in more than one format: Markdown and JSON for agents, images and pages for people. Below are three you are likely to post in a pull request or an issue. Add the path in each example to the trace API link to get the same output.

[Trace API](https://docs.currents.dev/ai/reference/trace-api) lists every route and option, with real output for each: the summary, the screen at any time, the page as text, accessibility tree or HTML, network requests and their bodies, the files in the trace, and the trace zip.

### Filmstrip

`/filmstrip?end=failure&layout=row&width=480` returns the frames up to the failure in one WebP image, and outlines the last one in red. That is the frame `/frames/failure` returns: the last frame before the failure, which can be seconds earlier while an assertion waits. From a failed test that expected a total of `$206.55` and got `$183.60`:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-1c054fd9bca5de62102d44868e3e3384c0e3cb6d%2Ftrace-filmstrip-failure-row.png?alt=media" alt="Three frames of the checkout in one row: save10 typed into the discount field with a total of $229.50, then the same, then outlined in red: SAVE10 applied: 10% off, a discount of −$22.95 and a total of $183.60"><figcaption><p><code>/filmstrip?end=failure&#x26;layout=row&#x26;width=480</code>: the failed test up to the failure</p></figcaption></figure>

### The page at the failure

`/snapshots/failure?format=html` returns the page when the test failed, with the styles from the trace. The trace API removes the scripts, so buttons and links do nothing. The same failed test, opened in a browser:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-740437e4360149b9cd165dedd62c84370446ebed%2Ftrace-snapshot-html.png?alt=media" alt="The checkout page rebuilt from the DOM snapshot at the failure: save10 in the discount field, SAVE10 applied: 10% off, a discount of −$22.95 and a total of $183.60"><figcaption><p><code>/snapshots/failure?format=html</code>: the page when the test failed, opened in a browser</p></figcaption></figure>

### Animation

`/animation?format=gif&width=640` returns the recording as a GIF, 640 pixels wide. A test that runs for a few seconds has only a few frames, so this one comes from the checkout session above:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-1144f441700ad6ba0f2799407ca6525384af2836%2Ftrace-animation-checkout.gif?alt=media" alt="An animation of the checkout: save10 is typed into the discount field, Apply is clicked, and the button stays on Applying… while the total stays at $229.50" width="584"><figcaption><p><code>/animation?format=gif&#x26;width=640</code>: the checkout session as a GIF</p></figcaption></figure>

GitHub shows these images in Markdown. Linear and Slack do not. See [Post evidence to GitHub, Slack and Linear](https://docs.currents.dev/ai/agentic-artifacts/post-evidence).


# Post to GitHub, Slack, Linear

Have an AI agent post what Currents recorded, such as a session, a shared run, a Fix link, or one screenshot, video or trace image from them, on a GitHub pull request, in Slack or on a Linear issue

This page works for CI runs and for sessions an agent recorded. An agent can post anything Currents recorded where your team already works: on the pull request, in the Slack thread, or on the Linear issue. Reviewers see the screenshots, the recording and the failure next to the code or the discussion. They do not open Currents, run the tests again or ask the agent what it did.

The agent can post a whole recording as one link: a CI run, a failed test or a browser session. It can also post single items from it: one screenshot, one video, one file, or an image or text from a Playwright trace.

## What you need

* An agent connected to Currents, or a share link that you give it. See [Connect your agent](https://docs.currents.dev/ai/connect) and [Share links](https://docs.currents.dev/ai/reference/share-links).
* A tool that lets the agent post to the place, such as the GitHub CLI, the Slack MCP server or the [Linear MCP server](https://linear.app/docs/mcp). Currents gives the agent the links. It does not post the messages itself.

## What to post

| You want to                                                                                   | The agent posts                                                                                                                                                              |
| --------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Report a failed CI test                                                                       | The error, the screen at the failure, and the [Fix link](https://docs.currents.dev/ai/reference/share-links), so another agent or person can fix it                          |
| [Prove a change with CI tests](https://docs.currents.dev/ai/agentic-testing/prove-a-change)   | What changed, the before and after from the run before the change and the run after it, and the run links                                                                    |
| [Prove a change that no test covers](https://docs.currents.dev/ai/agent-evidence/bug-and-fix) | What changed, the before and after screenshots, the page changes, and the session link                                                                                       |
| [Report the result of any task](https://docs.currents.dev/ai/agent-evidence/any-agent-task)   | What it did, the files it made, and the session link                                                                                                                         |
| Show results to someone without Currents access                                               | A summary and the link to a [Shared Run](https://docs.currents.dev/ai/agentic-testing/share-a-run) or a [Shared Session](https://docs.currents.dev/ai/reference/share-links) |

Give the page link to people. Give an agent the Markdown version: the same link with `.md` at the end.

## Post single items

The agent can also post one item from a recording instead of the whole link:

* One screenshot, video or other file from a session or a run
* From a Playwright trace: an [animation of the screen, a filmstrip](https://docs.currents.dev/ai/agentic-artifacts/explore-a-trace#available-formats) up to the failure, the screen at the failure, the page as it looked then, its accessibility tree, or a network request and its response

Ask for the items you want in the prompt. The agent gets each one from the trace API; see [Explore a trace](https://docs.currents.dev/ai/agentic-artifacts/explore-a-trace).

## GitHub

GitHub shows file links and trace images in Markdown, so the comment can hold the recording itself. Ask the agent:

```
Use the Currents MCP collect-evidence skill to collect before and after evidence
for this fix from CI, and post it on the pull request with gh. Show the
animation and the filmstrip of each run, and the API response that changed.
```

For the comment below, the prompt asked for the animation and the filmstrip of each run, the `ApplyDiscount` response, and the order summary from the accessibility tree. The agent got a trace API link for the failed test before the fix and one for the passed test after it, and built the comment from images and text of each trace:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-6fb33761fe7d92dcd51b55c27ec4acd8a63b47ca%2Fgithub-comment-trace-evidence.png?alt=media" alt="A pull request comment: SAVE10 total, before and after the fix. A table with the screencast and the filmstrip of each run, the filmstrip of the failed run outlined in red at the failure, the total of each run, and links to each trace, summary and page. Below it, the ApplyDiscount response and the order summary from the accessibility tree, each as a diff with the total 18360 before and 20655 after." width="620"><figcaption></figcaption></figure>

For a fix that no test covers, the agent posts the screenshots and the page changes from its session:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-3deeca8c135cc2e44298b3313535f537d3f96d4e%2Fgithub-comment-session-evidence.png?alt=media" alt="A pull request comment with the before and after screenshots of the checkout side by side, links to each session page and trace summary, and the accessibility tree changes as a diff" width="620"><figcaption></figcaption></figure>

The [GitHub App](https://docs.currents.dev/resources/integrations/github/github-app#run-comment) also comments on each pull request with the results of its CI run and a Fix link for each failed test. The agent's evidence is a separate comment.

## Slack

Slack shows links, not images from Markdown. The agent posts a few lines of what changed and the link:

```
Post the result in #checkout: one line on what was broken, one line on what
the fix changed, and the Currents session link.
```

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-d05d78c647e6950ab50dd98252fe71a3a194bca8%2Fslack-evidence-message.png?alt=media" alt="A Slack message: fixed the lowercase discount code bug, the before and after in two lines, the session link, and the Markdown link for an agent"><figcaption></figcaption></figure>

To report a failed CI test, ask for the error, the screen at the failure and the Fix link.

The [Slack App](https://docs.currents.dev/resources/integrations/slack/slack-app#fix-with-ai) posts failed CI tests to Slack with **Fix with AI**, which gives an agent the failure context. Reply in that thread with the evidence of the fix.

## Linear

Linear shows only images uploaded to Linear. A file link or a trace image link shows as "Failed to load image". The agent downloads the images, uploads them with the Linear MCP server, and puts the uploaded images in the comment:

```
Comment on ENG-123 with the before and after screenshots from the Currents
session: download them and upload them to Linear. Add what changed on the
page and the session link. Move the issue to In Review.
```

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-e77a919aaf521c1db32ea27a5dfc917bae907e06%2Flinear-evidence-comment.png?alt=media" alt="A Linear comment with the before and after screenshots of the checkout side by side, the page changes as a diff, and links to the Currents session and its Markdown version" width="620"><figcaption></figcaption></figure>

For a failed CI test, ask for the screen at the failure and the filmstrip from the trace, uploaded the same way, with the Fix link.

## When the links expire

Share links last 7 days at most. After that, an image in a GitHub comment stops showing, and the links stop opening. The text of the comment stays, and images uploaded to Linear stay. To show the evidence again, share the run or the session again and update the comment. See [Share links](https://docs.currents.dev/ai/reference/share-links).


# Agent skills

The agent skills Currents provides, what each is for, and how to make an agent use one

An [agent skill](https://agentskills.io/home) is a set of instructions an agent reads before it starts a task. A Currents skill tells the agent which tools to use, in which order, and what to check, so you write a short prompt instead of the steps.

To make sure the agent uses a skill, name it in the prompt, for example: "Use the Currents MCP collect-evidence skill".

| Skill                     | Use it when                                                  | How the agent gets it                                                                                                          |
| ------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
| `fix-failing-tests`       | CI is red, or a test fails                                   | [Currents MCP server skills](https://docs.currents.dev/ai/agent-skills/agent-skill-currents-mcp): nothing to install           |
| `collect-evidence`        | You need before and after evidence from CI runs              | [Currents MCP server skills](https://docs.currents.dev/ai/agent-skills/agent-skill-currents-mcp): nothing to install           |
| `browser-evidence`        | No test covers the change, and the agent records the browser | [Currents MCP server skills](https://docs.currents.dev/ai/agent-skills/agent-skill-currents-mcp): nothing to install           |
| `currents-cli`            | The agent has a shell and runs the `currents` command        | [Currents CLI skill](https://docs.currents.dev/ai/agent-skills/agent-skill-currents-cli): `npx currents skill --install`       |
| Playwright best practices | The agent writes or fixes Playwright tests                   | [Playwright best practices](https://docs.currents.dev/ai/agent-skills/agent-skill-playwright-best-practices): `npx skills add` |

If the agent is connected to the Currents MCP server, use the server's skills. If it only has a shell, install the `currents-cli` skill.


# Currents MCP server skills

The skills the Currents MCP server gives a connected agent: fix-failing-tests, collect-evidence and browser-evidence

An agent [connected to the Currents MCP server](https://docs.currents.dev/ai/connect) gets these skills with the tools. There is nothing to install.

| Skill               | What the agent does with it                                                                                                                           | See it at work                                                                              |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `fix-failing-tests` | Finds the failed run, reads each failure with its steps and trace, fixes the cause, runs the test again, and asks before it commits                   | [Fix failing CI tests](https://docs.currents.dev/ai/agentic-testing/fix-failing-tests)      |
| `collect-evidence`  | Finds the run before a change and the run after it, and writes up the before and after with links to the files                                        | [Prove a change with CI tests](https://docs.currents.dev/ai/agentic-testing/prove-a-change) |
| `browser-evidence`  | Records the browser before and after a change as a Currents session, and shares the link. This skill is experimental and can change between releases. | [Record a bug and its fix](https://docs.currents.dev/ai/agent-evidence/bug-and-fix)         |

Name the skill in the prompt, for example: "Use the Currents MCP fix-failing-tests skill".

The server gives each skill as an MCP prompt and as an MCP resource at `skill://currents/<name>/SKILL.md`. Some agents read skills only from a folder on disk. For those, save the resource to that folder.


# Currents CLI skill

The currents-cli skill teaches an agent with a shell to record sessions and use the currents command

The `currents-cli` skill teaches an agent to use the `currents` command: record a session, attach files and share the link. Use it when the agent has a shell but is not connected to the Currents MCP server.

The skill ships with the Currents CLI (`@currents/cmd`), so it always matches the version the agent runs:

* `npx currents skill` prints the skill.
* `npx currents skill --install` saves it to `.agents/skills`, where Codex and Cursor read skills. For Claude Code, add `--dir .claude/skills`.

To install the CLI and set a key, see [Install the Currents CLI and set a key](https://docs.currents.dev/ai/agent-evidence#install-the-currents-cli-and-set-a-key). For all options, see [currents skill](https://docs.currents.dev/resources/reporters/currents-cmd/currents-skill).

The Currents MCP server does not serve this skill. An agent that follows the server's `browser-evidence` skill and has a shell runs `currents docs sessions` instead, which prints the commands for the installed version.


# Playwright best practices

An agent skill that teaches AI agents to write, debug and maintain Playwright tests the way an experienced Playwright engineer would

Without guidance, agents write Playwright tests from generic patterns: `waitForTimeout` calls, brittle CSS selectors, and retries that hide real bugs. This [agent skill](https://agentskills.io/home) gives them Playwright practice instead: locators, web-first assertions, debugging flaky tests, CI setup and more.

```bash
npx skills add https://github.com/currents-dev/playwright-best-practices-skill
```

The source is [on GitHub](https://github.com/currents-dev/playwright-best-practices-skill). It works in Claude Code, Cursor, VS Code, Gemini CLI and other agents that read skills. The agent loads it when a task involves Playwright; you do not need to name it.

## What it covers

| Area                | Examples                                                                          |
| ------------------- | --------------------------------------------------------------------------------- |
| Writing tests       | E2E, component, API, visual regression and accessibility tests                    |
| Fixing tests        | Flaky tests, timeouts in CI, debugging failures                                   |
| Browser features    | File uploads, OAuth popups, multi-tab flows, iframes, service workers, WebSockets |
| Devices and locales | Mobile layouts, touch gestures, geolocation, i18n and RTL                         |
| Test structure      | Page Object Model, fixtures, global setup and teardown                            |
| CI and scale        | Projects, dependencies, parallel runs and sharding                                |
| Other apps          | Electron apps and browser extensions                                              |

Example prompts:

* "Fix this flaky login test."
* "Add a test for the checkout flow."
* "Mock the payment gateway in tests."
* "Set up sharding for our test suite in CI."


# Connect your agent

Connect Claude, Cursor, Codex, ChatGPT, your editor or any other MCP client to Currents, and pick the setup that fits where you work

Currents hosts an MCP server at `https://mcp.currents.dev/mcp`. A connected agent reads your runs, test results, failure evidence and analytics, and acts on them, for example to quarantine a flaky test or open a Jira issue. There is nothing to install.

## Pick your agent

| Agent                                                                       | Where you use it                             | Setup                                                                                                                                            |
| --------------------------------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| [Claude Code](https://docs.currents.dev/ai/connect/claude-code)             | Terminal, VS Code, JetBrains                 | Use the [Currents connector](https://claude.ai/directory/currents), then sign in                                                                 |
| [Cursor](https://docs.currents.dev/ai/connect/cursor)                       | Cursor                                       | Open the [install link](https://cursor.com/install-mcp?name=currents\&config=eyJ1cmwiOiJodHRwczovL21jcC5jdXJyZW50cy5kZXYvbWNwIn0=), then sign in |
| [Claude Desktop and Claude.ai](https://docs.currents.dev/ai/connect/claude) | Claude Desktop, Claude.ai, Claude mobile app | Use the [Currents connector](https://claude.ai/directory/currents), then sign in                                                                 |
| [Codex](https://docs.currents.dev/ai/connect/codex)                         | Codex CLI, Codex app, ChatGPT desktop app    | Install from the [plugin directory](https://chatgpt.com/plugins/plugin_asdk_app_6abc73667f608191b7511e1375170326), then sign in                  |
| [ChatGPT](https://docs.currents.dev/ai/connect/chatgpt)                     | Chatgpt.com, ChatGPT desktop app             | Install from the [plugin directory](https://chatgpt.com/plugins/plugin_asdk_app_6abc73667f608191b7511e1375170326), then sign in                  |

Currents publishes two official listings: [Currents in the Claude directory](https://claude.ai/directory/currents) and [Currents in the ChatGPT plugin directory](https://chatgpt.com/plugins/plugin_asdk_app_6abc73667f608191b7511e1375170326), which serves both ChatGPT and Codex.

Other ways to connect:

* [IDE Extension](https://docs.currents.dev/ai/connect/ide-extension): shows Currents results in VS Code, Cursor and compatible editors, and adds the MCP server for the editor's agent.
* [Any MCP client](https://docs.currents.dev/ai/connect/remote): enter the server URL, then sign in or add an API key.
* [Local MCP Server](https://docs.currents.dev/ai/connect/local): runs the server on your machine with an API key, for clients that can only start local servers.

## Try it

Ask about your own projects:

* "Which tests in `<project>` were flakiest on main this week, and why?"
* "What broke in the last failed `<project>` run on main? Open a Jira issue for it."
* "Is this pull request safe to merge? Compare its runs with main."
* "Which spec files got slowest over the last 30 days?"

The agent picks the tools. [MCP tools and permissions](https://docs.currents.dev/ai/reference/mcp-server) lists them. Keep your agent set to ask before it calls a write tool: `currents-delete-run` deletes a run permanently, and Currents does not ask for confirmation.

## Sign in once

The first time an agent calls Currents, a browser window opens:

1. Sign in to Currents. SSO works as it does for the dashboard.
2. Choose the organization. The agent works in that organization only. To use two organizations, connect twice.
3. Approve the permissions the agent asks for. Your role sets which ones you can approve: for example, a Guest can approve reading projects and results only.

The agent renews its access after that. [OAuth](https://docs.currents.dev/authentication/oauth) explains each screen and permission.

A client that cannot complete this sign-in can send an [API key](https://docs.currents.dev/ai/connect/remote#connect-with-an-api-key) instead. A key acts as the organization, not as you.

## Revoke a connection

**Account → Connected Applications** lists every agent you authorized, what it can read and write, and when it was last used. Remove one to end its access on every machine. An admin sees everyone's connections under **Manage Organization → Connected Applications**. See [Reviewing and revoking access](https://docs.currents.dev/authentication/oauth#reviewing-and-revoking-access).

A connection made with an API key is not listed there. To end it, an admin revokes the key under **Organization → API Keys**.

## Troubleshooting

| What you see                     | What to do                                                                                                                                                          |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| A tool you expect is missing     | Your grant or your role does not include its permission. See [the role sets the ceiling](https://docs.currents.dev/authentication/oauth#the-role-sets-the-ceiling). |
| The wrong organization's data    | Each connection reaches one organization. Revoke it, connect again, and choose the other one.                                                                       |
| `403` `organization_not_enabled` | Contact <support@currents.dev>.                                                                                                                                     |

Each agent's page lists the errors specific to that agent. For HTTP errors from the server, see [Connect any MCP client](https://docs.currents.dev/ai/connect/remote#troubleshooting).


# Claude Code

Use your Claude.ai Currents connector in Claude Code with no setup, or add the server with one command and a browser sign-in

Claude Code connects to the Currents MCP server at `https://mcp.currents.dev/mcp`. If you sign in to Claude Code with a Claude.ai account, use the Currents connector from Claude.ai. Otherwise, add the server to Claude Code yourself.

## Use the Claude.ai connector

If you sign in to Claude Code with a Claude.ai account, Claude Code loads the connectors you connected in Claude.ai. You do not need to run `claude mcp add`.

1. Connect Currents from the [Claude directory](https://claude.ai/directory/currents). Skip this step if you already connected it.
2. Start Claude Code and run `/mcp`.
3. Look for **claude.ai Currents MCP**. It shows as connected.

The connector follows your Claude account to every machine where you sign in.

If **claude.ai Currents MCP** is missing, run `/status` to see which credential Claude Code uses.

Claude Code loads Claude.ai connectors only with a Claude.ai login. It does not load them with `ANTHROPIC_API_KEY`, a `claude setup-token` token, Amazon Bedrock or Google Vertex AI.\
\
In that case, [add the server yourself](#add-the-server-yourself). See [Use MCP servers from claude.ai](https://code.claude.com/docs/en/mcp#use-mcp-servers-from-claude-ai).

## Add the server yourself

Use this method if Claude Code does not use a Claude.ai login, or if you want the server only in Claude Code.

{% hint style="warning" %}
Use the connector or this server, not both. If you set up both, Claude Code shows two Currents servers with two sets of tool names.
{% endhint %}

```bash
claude mcp add --transport http --scope user currents https://mcp.currents.dev/mcp
```

`--scope user` makes Currents available in every project on this machine. To share it with your team, see [Share the server with your team](#share-the-server-with-your-team).

## Sign in

1. Start Claude Code and run `/mcp`.
2. Select **currents** and choose **Authenticate**. A browser window opens.
3. Sign in to Currents, choose the organization Claude Code will work in, and approve the permissions it asks for. See [Sign in once](https://docs.currents.dev/ai/connect#sign-in-once) for what each screen shows.
4. Return to Claude Code. `/mcp` now shows **currents** as connected.

On a machine with no browser, run `claude mcp login currents --no-browser`. It prints the sign-in URL for you to open elsewhere, and asks you to paste back the address the browser lands on.

Claude Code renews the connection on its own from then on. `claude mcp logout currents` clears it on this machine. To revoke it everywhere, remove **Claude Code** under **Account → Connected Applications** in Currents.

## Check the connection

```bash
claude mcp list
```

`currents` shows `✔ Connected` once you are signed in, and `! Needs authentication` before that. Then ask Claude Code something only Currents can answer:

> What failed in the last run of `<project>` on main, and which of those tests are flaky?

If you use the Claude.ai connector, run `/mcp` and look for **claude.ai Currents MCP**.

## Ask before writes

Claude Code asks before it calls any MCP tool. To let it run the read tools on its own and keep asking for writes, allow the read tools by name in `.claude/settings.json`.

The tool names depend on how you connected Currents. A server you added names each tool `mcp__currents__<tool>`. The Claude.ai connector uses its name from Claude.ai, for example `mcp__claude_ai_Currents__<tool>`.\
\
To see the exact names, run `/mcp`, select the Currents connector and choose **View tools**.\
\
The Claude.ai connector example below uses a connector named **Currents**. If your connector has another name, change the prefix to match the names in **View tools**.

{% tabs %}
{% tab title="Server you added" %}

```json
{
  "permissions": {
    "allow": [
      "mcp__currents__currents-get-projects",
      "mcp__currents__currents-get-runs",
      "mcp__currents__currents-get-run-details",
      "mcp__currents__currents-find-run",
      "mcp__currents__currents-get-test-results",
      "mcp__currents__currents-get-context",
      "mcp__currents__currents-get-tests-performance"
    ]
  }
}
```

{% endtab %}

{% tab title="Claude.ai connector" %}

```json
{
  "permissions": {
    "allow": [
      "mcp__claude_ai_Currents__currents-get-projects",
      "mcp__claude_ai_Currents__currents-get-runs",
      "mcp__claude_ai_Currents__currents-get-run-details",
      "mcp__claude_ai_Currents__currents-find-run",
      "mcp__claude_ai_Currents__currents-get-test-results",
      "mcp__claude_ai_Currents__currents-get-context",
      "mcp__claude_ai_Currents__currents-get-tests-performance"
    ]
  }
}
```

{% endtab %}
{% endtabs %}

Do not allow a Currents server or connector as a whole, for example `mcp__currents`. Each one includes `currents-delete-run`, which deletes a run permanently. [MCP tools and permissions](https://docs.currents.dev/ai/reference/mcp-server) lists every tool.

## Other options

### Share the server with your team

`--scope` decides where Claude Code saves the entry:

| Scope             | Available in                                    | Saved in                           |
| ----------------- | ----------------------------------------------- | ---------------------------------- |
| `user`            | Every project on this machine                   | `~/.claude.json`                   |
| `local` (default) | The current project, for you                    | `~/.claude.json`                   |
| `project`         | The current project, for everyone who clones it | `.mcp.json` in the repository root |

Add the server with `--scope project` and commit the `.mcp.json` it writes:

```json
{
  "mcpServers": {
    "currents": {
      "type": "http",
      "url": "https://mcp.currents.dev/mcp"
    }
  }
}
```

The file holds no credential. Each person who opens the project approves the server and signs in as themselves, so the connection carries their own role and organization.

### Use an API key

For a CI job, or anywhere no one can complete the browser sign-in, send a Currents API key in a header:

```bash
claude mcp add --transport http currents https://mcp.currents.dev/mcp \
  --header "Authorization: Bearer $CURRENTS_API_KEY"
```

In a committed `.mcp.json`, read the key from the environment so it never lands in the repository:

```json
{
  "mcpServers": {
    "currents": {
      "type": "http",
      "url": "https://mcp.currents.dev/mcp",
      "headers": {
        "Authorization": "Bearer ${CURRENTS_API_KEY}"
      }
    }
  }
}
```

A key acts as the organization, not as a person. See [Connect with an API key](https://docs.currents.dev/ai/connect/remote#connect-with-an-api-key) for what a key can reach and how to revoke it.

## Troubleshooting

| What you see                                      | What to do                                                                                                                |
| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `! Needs authentication`                          | Run `/mcp`, select **currents** and choose **Authenticate**.                                                              |
| The wrong organization's data                     | Run `claude mcp logout currents`, then authenticate again and choose the other organization.                              |
| **claude.ai Currents MCP** is missing from `/mcp` | Run `/status`. If the credential is not a Claude.ai login, run `/login`, or add the server yourself.                      |
| Two Currents servers in `/mcp`                    | Keep one. Run `claude mcp remove currents` to keep the connector, or disconnect Currents in Claude.ai to keep the server. |

For other errors, see [Troubleshooting](https://docs.currents.dev/ai/connect#troubleshooting).


# Cursor

Connect Cursor to the Currents MCP server with an install link and a browser sign-in, for yourself or for everyone working in a repository

Cursor connects to the Currents MCP server at `https://mcp.currents.dev/mcp`. Add the server once and sign in, and the Cursor agent can read your runs and test results and act on them.

## Add the server

Open the [install link](https://cursor.com/install-mcp?name=currents\&config=eyJ1cmwiOiJodHRwczovL21jcC5jdXJyZW50cy5kZXYvbWNwIn0=) and confirm in Cursor.

To add it by hand, put this in `~/.cursor/mcp.json` for every project, or in `.cursor/mcp.json` at the repository root to share it with everyone who works in the repository:

```json
{
  "mcpServers": {
    "currents": {
      "url": "https://mcp.currents.dev/mcp"
    }
  }
}
```

The file holds no credential. Each person signs in as themselves.

## Sign in

Cursor signs in with OAuth. A browser window opens: sign in to Currents, choose the organization Cursor will work in, and approve the permissions it asks for. See [Sign in once](https://docs.currents.dev/ai/connect#sign-in-once) for what each screen shows.

## Check the connection

Ask the Cursor agent something only Currents can answer:

> Which tests in `<project>` were flakiest on main this week, and why?

If the Currents tools do not show up, open the Output panel and select MCP Logs. The logs show the server start, the tool calls and the errors.

Cursor asks before it uses an MCP tool. Keep it that way for write tools: `currents-delete-run` deletes a run permanently. See the [Cursor MCP documentation](https://cursor.com/docs/context/mcp).

## Skills

Cursor reads skills from `.agents/skills`, where `npx currents skill --install` saves the [Currents CLI skill](https://docs.currents.dev/ai/agent-skills/agent-skill-currents-cli). See [Agent skills](https://docs.currents.dev/ai/agent-skills) for the other Currents skills.

For an API key instead of a sign-in, and for errors, see [Connect any MCP client](https://docs.currents.dev/ai/connect/remote).


# Claude Desktop and Claude.ai

Connect Currents to Claude Desktop and Claude.ai from the Claude directory, for yourself or for your whole Claude organization

Currents is listed as a connector in the [Claude directory](https://claude.ai/directory/currents). Claude lists connectors, skills and plugins on one **Plugins** page. A connector belongs to your Claude account rather than to one device, so connecting once makes Currents available in Claude Desktop, Claude.ai, the Claude mobile app, Cowork and [Claude Code](https://docs.currents.dev/ai/connect/claude-code).

Claude is replacing **Customize** with **Plugins** gradually, and Enterprise plans switch on November 30, 2026. If your sidebar still shows **Customize**, open **Customize → Connectors** where this page says **Plugins**, and **Organization settings → Connectors** where it says **Organization settings → Plugins → Connectors**.

## Connect from the Claude directory

{% tabs %}
{% tab title="Free, Pro, Max and Ultra" %}

1. Open the [Currents listing in the Claude directory](https://claude.ai/directory/currents). Or, in Claude Desktop or Claude.ai, click **Plugins** in the sidebar, then search for **Currents**.
2. Click **Connect to Claude**, then [sign in](#sign-in).

The directory listing works on every plan, including Free, and there is no URL to enter.
{% endtab %}

{% tab title="Team and Enterprise" %}
An Owner adds Currents for the organization first:

1. Open [claude.ai/directory/currents](https://claude.ai/directory/currents).
2. Click **Connect for your team**. Currents is now available to everyone in the organization.
3. Click **Connect to Claude** to connect your own Currents account.

Owners can also add Currents from **Organization settings → Plugins → Connectors → Browse connectors**.

Each member then connects with their own Currents account:

1. Click **Plugins** in the sidebar and find **Currents**.
2. Click **Connect to Claude**, then [sign in](#sign-in).

On a Team plan, a member without permission to enable connectors sees **Request** instead of a connect button. **Request** sends the request to the organization's Owners, who approve it in **Organization settings**.

Adding the connector gives nobody access to Currents data. Each member signs in to Currents themselves, and their connection carries their own Currents role.
{% endtab %}
{% endtabs %}

## Sign in

**Connect to Claude** opens a Currents sign-in page. Sign in, choose the organization Claude will work in, and approve the permissions Claude asks for. The browser then returns you to Claude, and the connector shows as connected. See [Sign in once](https://docs.currents.dev/ai/connect#sign-in-once) for what each screen shows.

## Use it in a chat

Click **+** at the bottom left of the message box, open **Connectors**, and make sure **Currents** is turned on for the conversation. Then ask about your projects:

> Which tests in `<project>` were flakiest on main this week, and why?

The **Search and tools** menu lets you turn off individual Currents tools before Claude calls them. Turn off the ones a conversation does not need, especially `currents-delete-run`, which permanently deletes a run. Currents does not ask for confirmation.

## Disconnect

1. Open the [Currents listing in the Claude directory](https://claude.ai/directory/currents).
2. Open the three-dot menu next to **Connected** and select **Disconnect**.

Disconnecting removes Currents from Claude. To revoke Claude's access from the Currents side, see [Revoke a connection](https://docs.currents.dev/ai/connect#revoke-a-connection).

## Other ways to connect

### Add Currents by URL

Use a custom connector only when the directory listing is not available to you.

**Free, Pro, Max and Ultra:**

1. In Claude Desktop or Claude.ai, click **Plugins** in the sidebar.
2. Click **+ Add**, then **Add custom connector**.
3. Name it `Currents`.
4. Enter the URL `https://mcp.currents.dev/mcp`, then click **Continue**.
5. Keep the authentication settings Claude detects, then click **Continue**.
6. Under **OAuth client**, keep **Use Claude's published identity (Recommended)**. Claude identifies itself to Currents on its own, so there is no client ID or secret to enter.
7. Leave **Request headers** empty.
8. Click **Add**, then [sign in](#sign-in).

On the Free plan, Claude allows one custom connector.

**Team and Enterprise:** an Owner adds the custom connector for the organization, and members without permission see **Add custom connector** turned off. The Owner opens **Organization settings → Plugins → Connectors**, clicks **Add**, hovers over **Custom** and chooses **Web**. The Owner then follows steps 3 to 7 above and clicks **Add**. Members then connect as described in the **Team and Enterprise** tab above.

### If you added Currents by URL before

A custom connector you added earlier keeps working. Connecting from the directory as well gives you two Currents connections.

To keep only the directory connection:

1. Click **Plugins** in the sidebar and open the Currents connector you added by URL.
2. Open the three-dot menu and select **Remove**. On Team and Enterprise plans, an Owner removes it under **Organization settings → Plugins → Connectors**.
3. Connect from [claude.ai/directory/currents](https://claude.ai/directory/currents) and sign in again.

### Run the server on your computer

Claude Desktop can also run the Currents MCP server on your computer, with an API key instead of your own sign-in. This works in Claude Desktop only, not on Claude.ai. Open **Settings → Developer → Edit Config** and add the configuration from [Local MCP Server](https://docs.currents.dev/ai/connect/local) to `claude_desktop_config.json`, then restart Claude Desktop. A local setup creates no entry under **Connected Applications**: the key keeps working until an Admin revokes it under **Organization → API Keys**.

The connector from the directory needs nothing installed, and its access follows your own Currents role.

## Troubleshooting

| What you see                        | What to do                                                                                                                          |
| ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| Claude does not use Currents        | Check that **Currents** is turned on under **+ → Connectors** for this conversation.                                                |
| The wrong organization's data       | Disconnect, connect again, and choose the other organization.                                                                       |
| Two Currents connectors in the list | One is a custom connector added by URL. Remove it. See [If you added Currents by URL before](#if-you-added-currents-by-url-before). |

For other errors, see [Troubleshooting](https://docs.currents.dev/ai/connect#troubleshooting).


# Codex

Install the Currents plugin in the Codex CLI or the Codex app and sign in, or add the Currents MCP server with codex mcp add for the IDE extension

Currents is listed in the Codex plugin directory as [Currents](https://chatgpt.com/plugins/plugin_asdk_app_6abc73667f608191b7511e1375170326). Install it in the Codex CLI or the Codex app and sign in to Currents, and Codex can read your runs, test results, failure evidence and analytics. There is no server URL to enter.

The plugin brings the [Currents MCP server skills](https://docs.currents.dev/ai/agent-skills/agent-skill-currents-mcp) with it: `fix-failing-tests`, `collect-evidence` and `browser-evidence`. Codex knows those workflows without being told.

Codex and [ChatGPT](https://docs.currents.dev/ai/connect/chatgpt) share one plugin directory, so the same Currents plugin is the one to install in both.

## Install the Currents plugin

{% tabs %}
{% tab title="Codex CLI" %}

1. Run `codex`, then enter `/plugins`.
2. Find **Currents** and install it.
3. Start a new session, then [sign in](#sign-in) when Codex asks you to connect.
   {% endtab %}

{% tab title="Codex app" %}

1. In the Codex app or the ChatGPT desktop app, open the **Plugins** tab.
2. Find **Currents** and select the plus button.
3. When Codex asks you to connect, [sign in](#sign-in).
4. Start a new chat.
   {% endtab %}
   {% endtabs %}

The Codex IDE extension does not support plugins. For the IDE extension, [add the server by URL](#add-the-server-by-url).

## Sign in

A browser window opens. Sign in to Currents, choose the organization Codex will work in, and approve the permissions it asks for. See [Sign in once](https://docs.currents.dev/ai/connect#sign-in-once) for what each screen shows.

Codex renews the connection on its own from then on. To revoke it everywhere, remove it under **Account → Connected Applications** in Currents.

## Check the connection

Type `/mcp` inside a `codex` session to see the active servers. Then ask something only Currents can answer:

> Which tests in `<project>` were flakiest on main this week, and why?

## Add the server by URL

Add the server with `codex mcp add` in these cases:

* You use the Codex IDE extension, which does not support plugins.
* You sign in to Codex with an OpenAI API key instead of a ChatGPT account. With an API key, the plugin directory offers only plugins that do not need an OAuth sign-in, and Currents does.
* You want to share the server with everyone working in a repository.

```bash
codex mcp add currents --url https://mcp.currents.dev/mcp
```

This writes an entry to `~/.codex/config.toml`:

```toml
[mcp_servers.currents]
url = "https://mcp.currents.dev/mcp"
```

The Codex CLI, the Codex IDE extension and the ChatGPT desktop app read the same configuration, so the entry makes Currents available in all three. To share the server with everyone working in a repository, put the same table in `.codex/config.toml` at the repository root instead. Codex reads project configuration from trusted projects only. The file holds no credential: each person signs in as themselves.

Then sign in:

```bash
codex mcp login currents
```

Run `codex mcp list` to see the configured servers.

### Ask before writes

Every Currents tool says whether it only reads. Have Codex ask you before any tool that does not:

```toml
[mcp_servers.currents]
url = "https://mcp.currents.dev/mcp"
default_tools_approval_mode = "writes"
```

With this, Codex runs the read tools on its own and stops for writes such as `currents-delete-run`, which permanently deletes a run. `enabled_tools` and `disabled_tools` narrow the list further. See the [Codex MCP documentation](https://learn.chatgpt.com/docs/extend/mcp).

### Use an API key instead

For a CI job or anywhere no one can complete the browser sign-in, send a Currents [API key](https://docs.currents.dev/dashboard/administration/api-keys) from an environment variable:

```bash
codex mcp add currents --url https://mcp.currents.dev/mcp \
  --bearer-token-env-var CURRENTS_API_KEY
```

```toml
[mcp_servers.currents]
url = "https://mcp.currents.dev/mcp"
bearer_token_env_var = "CURRENTS_API_KEY"
```

A key acts as the organization, not as a person. See [Connect with an API key](https://docs.currents.dev/ai/connect/remote#connect-with-an-api-key) for what a key can reach and how to revoke it.

### If you added the server by URL before

A server you added with `codex mcp add` keeps working. Installing the plugin as well gives Codex two Currents connections. To move to the plugin, run `codex mcp remove currents`, then [install the Currents plugin](#install-the-currents-plugin). Keep the entry if you also use the IDE extension.

## Troubleshooting

| What you see                   | What to do                                                                                                                  |
| ------------------------------ | --------------------------------------------------------------------------------------------------------------------------- |
| No Currents in `/plugins`      | Check that you signed in to Codex with a ChatGPT account. With an API key, [add the server by URL](#add-the-server-by-url). |
| Currents tools fail with `401` | Reinstall the plugin and sign in again. For a server added by URL, run `codex mcp login currents`.                          |
| The wrong organization's data  | Revoke the connection in Currents, sign in again, and choose the other organization.                                        |

For other errors, see [Troubleshooting](https://docs.currents.dev/ai/connect#troubleshooting).


# ChatGPT

Install the Currents plugin from the ChatGPT plugin directory and sign in, or add Currents as a developer-mode app when the directory is not available to you

Currents is listed in the ChatGPT plugin directory as [Currents](https://chatgpt.com/plugins/plugin_asdk_app_6abc73667f608191b7511e1375170326). Install it once and sign in to Currents, and ChatGPT can read your runs, test results, failure evidence and analytics in any new chat. There is no server URL to enter and no app to create.

The plugin brings the [Currents MCP server skills](https://docs.currents.dev/ai/agent-skills/agent-skill-currents-mcp) with it: `fix-failing-tests`, `collect-evidence` and `browser-evidence`. ChatGPT knows those workflows without being told.

ChatGPT and [Codex](https://docs.currents.dev/ai/connect/codex) share one plugin directory, so the same Currents plugin is the one to install in both.

## Install the Currents plugin

1. Open [the Currents plugin](https://chatgpt.com/plugins/plugin_asdk_app_6abc73667f608191b7511e1375170326). Or, in ChatGPT, open **Plugins** and search for **Currents**.
2. Install the plugin.
3. When ChatGPT asks you to connect, [sign in](#sign-in).

On a Business, Enterprise or Education workspace, an admin decides who can use plugins. If Currents shows **Disabled by admin**, ask your workspace admin to allow it, or [add Currents as a developer-mode app](#add-currents-as-a-developer-mode-app).

## Sign in

When ChatGPT first connects, a Currents sign-in page opens. Sign in, choose the organization ChatGPT will work in, and approve the permissions it asks for. See [Sign in once](https://docs.currents.dev/ai/connect#sign-in-once) for what each screen shows. ChatGPT renews the connection on its own after that.

## Use it in a chat

Start a new chat after you install the plugin. Describe the task and ChatGPT picks the Currents tools, or type `@` and choose **Currents** or one of its skills. Then ask about your projects:

> What broke in the last failed run of `<project>` on main? Open a Jira issue for it.

ChatGPT asks you to confirm tool calls that change data. Check the input before you confirm a write, especially `currents-delete-run`, which permanently deletes a run. Currents does not ask for confirmation.

To revoke ChatGPT's access from the Currents side, see [Revoke a connection](https://docs.currents.dev/ai/connect#revoke-a-connection).

## Other ways to connect

### Add Currents as a developer-mode app

Use a developer-mode app only when your workspace does not allow the Currents plugin. Developer mode is available on the web for Plus, Pro, Business, Enterprise and Education accounts. On a Business, Enterprise or Education workspace, an admin may need to allow it first.

1. In [ChatGPT](https://chatgpt.com), open **Settings → Security and login** and turn on **Developer mode**.
2. Go to [ChatGPT Plugins](https://chatgpt.com/plugins) and select the plus button.
3. Fill in the app details:
   * **Name**: `Currents`
   * **Description**: `Test results, flaky tests and CI failures from Currents`
   * **MCP server URL**: `https://mcp.currents.dev/mcp`
   * **Authentication**: OAuth
4. Leave the client ID and secret empty. ChatGPT identifies itself to Currents on its own. If ChatGPT asks how to register, choose the Client ID Metadata Document option.
5. Create the app, then [sign in](#sign-in). The app is listed under **Drafts** in your app settings.

To use the app, open the **+** menu in the composer, choose **Developer mode**, and select **Currents**. The app's details page in your app settings turns individual Currents tools on or off, and refreshes the app to pick up tools Currents has added since you created it.

### If you created a developer-mode app before

A developer-mode app you created earlier keeps working. Installing the plugin as well gives you two Currents connections. To move to the plugin, delete the app from your app settings, then [install the Currents plugin](#install-the-currents-plugin) and sign in again.

## Troubleshooting

| What you see                         | What to do                                                                                                                  |
| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------- |
| Currents shows **Disabled by admin** | Ask your workspace admin to allow the Currents plugin.                                                                      |
| ChatGPT does not use Currents        | Start a new chat, then type `@` and choose **Currents**.                                                                    |
| Two Currents entries                 | One is a developer-mode app. See [If you created a developer-mode app before](#if-you-created-a-developer-mode-app-before). |

For other errors, see [Troubleshooting](https://docs.currents.dev/ai/connect#troubleshooting).


# IDE Extension

See CI runs and failures in VS Code or Cursor, and send a failure to your AI agent with its full context

The Currents extension shows your CI runs, failures and flaky tests in the editor, and sends a failure to your AI agent with its full context. It works in VS Code, Cursor and other editors that use the [Open VSX](https://open-vsx.org/) registry.

You need:

* A Currents account in an organization, or an API key
* VS Code 1.85 or later, or Cursor

## Install the extension

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FTJCywA9tFiM8Kge9RU6g%2FCleanShot%202026-05-18%20at%2010.26.20%402x.png?alt=media&amp;token=20da0f47-737d-4ef8-a4eb-5b59e41954c6" alt="The Currents extension page in the VS Code Marketplace"><figcaption></figcaption></figure>

* [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=currents.currents)
* [Open VSX Registry](https://open-vsx.org/extension/currents/currents) (Cursor and other VS Code forks)

Or search "Currents" in the Extensions panel of your editor.

## Sign in and pick a project

1. Open the Currents panel in the Activity Bar.
2. Click **Connect to Currents** and sign in from the browser. On a remote machine, run **Currents: Copy Sign-In Link** and open the link yourself.
3. Select a project. Its runs appear in the panel.

Where a browser sign-in is not practical, run **Currents: Set API Key** and paste an [API key](https://docs.currents.dev/dashboard/administration/api-keys) instead. If you keep both, the extension uses the sign-in.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2F4P70XWxxBKlWu2zonpcr%2FCleanShot%202026-05-18%20at%2010.56.46%402x.png?alt=media&amp;token=3526c687-3402-43ce-8ade-2eb5a0cfd77f" alt="Currents extension settings with the Set API Key button"><figcaption></figcaption></figure>

## See CI failures

{% embed url="<https://player.mux.com/F8NYHWt01dG5KB00UGv7HOYNwzlKEIGBKqcLivLGhi3YA?metadata-video-title=Currents+IDE+Extension&video-title=Currents+IDE+Extension>" %}

### Run Feed

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FUevYoPeLc14vijFgKe9n%2FCleanShot%202026-05-18%20at%2011.29.56%402x.png?alt=media&amp;token=417f11de-a5e8-479e-8908-050d1279e814" alt="The run feed in the Currents panel"><figcaption></figcaption></figure>

The latest CI runs, refreshed every 30 seconds.

* Filter by branch, author, tags, or status
* Toggle auto-refresh on or off
* Load older runs on demand

### Pull Requests

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FpPSql7JWBDd6M2jgZrrt%2FCleanShot%202026-05-18%20at%2011.31.21%402x.png?alt=media&amp;token=6aee8ef0-20f3-4798-b927-3a40bf21cf9f" alt="Pull requests with their commits and builds"><figcaption></figcaption></figure>

CI failures grouped by pull request, with a timeline of commits and builds for each one.

* Filter by branch, author, tags, or status
* Toggle auto-refresh on or off

### Run Details

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2F7wa2bc3zPcaacYuJBzgK%2FCleanShot%202026-05-18%20at%2011.32.36%402x.png?alt=media&amp;token=e8b1f467-f3a0-4918-85e2-f3cd6b1de6b9" alt="Run details with a failed test, its error, and the Fix with agent and Trace Viewer actions"><figcaption></figcaption></figure>

Every spec and test of a run, with errors and stack traces for failed tests.

* **Fix All Issues** and **Fix with agent**: see [Fix with AI](#fix-with-ai)
* **Go to file**: jump to the test file and line in one click
* **Trace Viewer**: open the Playwright Trace Viewer inline (see [Inline Trace Viewer](#inline-trace-viewer) below)
* **Open in Dashboard**: open the full Currents dashboard for deeper analysis of the run, spec, or test attempt

## Fix failures with your agent

### Fix with AI

{% embed url="<https://player.mux.com/h7mDts1TwwARJseGM01u0001W638rJB9TKLlr01rkLRNtMI?metadata-video-title=Currents+IDE+Error+Context&video-title=Currents+IDE+Error+Context>" %}

The Fix actions send your editor's AI agent a prompt with the [failure context](https://docs.currents.dev/ai/agentic-testing/fix-failing-tests#what-the-context-contains): the error and stack, the test's history, and the error-context snapshot: the page's accessibility tree at the moment of failure.

| Action                                      | Sends                                                                      |
| ------------------------------------------- | -------------------------------------------------------------------------- |
| **Fix with agent** on a test                | That test's context                                                        |
| **Fix all failures in spec** on a spec file | The failed tests of that spec file, or its flaky tests                     |
| **Fix All Issues** on a run                 | The failures of the whole run                                              |
| **Fix With Agent** in Test Explorer         | The flakiness rate or average duration, for the agent to look into via MCP |

In an editor without a built-in chat, the prompt is copied to the clipboard.

### Analyze with Currents

**Analyze with Currents** appears above every `test`, `it`, `describe` and `context` in your code. It asks your agent to check the test's recent results in Currents for failures, flakiness and slowdowns, and to plan a fix. It is also a Quick Fix (Cmd+. or Ctrl+.) on any test line.

### The Currents MCP server

The extension adds the [Currents MCP server](https://docs.currents.dev/ai/connect/remote) to the editor, connected as you, so the agent can ask Currents for more after the first prompt. Signing out removes it. Turn this off with `currents.registerMcpServer` if you set up the MCP server yourself.

## View a trace

### Inline Trace Viewer

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FSjNHI8znQkxxhccgSbfN%2FCleanShot%202026-05-18%20at%2011.36.23.gif?alt=media&amp;token=6d30e52a-7e6f-4540-b5f8-e1f5c25143a7" alt="The Playwright Trace Viewer in an editor tab next to the test code"><figcaption></figcaption></figure>

Click **Trace Viewer** on a failed attempt to open the Playwright Trace Viewer in an editor tab, next to your code. The trace streams from Currents, so there is nothing to download. Another trace opens in the same tab. **Open in browser** opens it in a browser window.

## Explore flaky and slow tests

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2F8Q8LYJyra0664dQ5TxQ4%2FCleanShot%202026-05-18%20at%2011.34.05%402x.png?alt=media&amp;token=12507b4a-a0fb-4537-af5c-77d1552fdbe9" alt="Test Explorer sorted by flakiness"><figcaption></figcaption></figure>

**Test Explorer** lists the flakiest and slowest tests of the project over 14, 30, 60 or 90 days.

* Sort by flakiness rate or average duration
* Jump to the test file and line in one click
* Send flaky or slow tests to AI for analysis and automated fixes
* Open in Dashboard for historical trends

## Settings

| Setting                          | Default                       | Description                                                                                 |
| -------------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------- |
| `currents.filterByCurrentBranch` | `false`                       | Auto-filter runs by the current git branch when a project is selected                       |
| `currents.notifyOnRunComplete`   | `false`                       | Show an OS notification when a run finishes                                                 |
| `currents.analyzeTestDisplay`    | `always`                      | Show "Analyze with Currents" above each test (`always`) or only as a Quick Fix (`quickfix`) |
| `currents.apiBaseUrl`            | `https://api.currents.dev/v1` | API base URL (for self-hosted or enterprise setups)                                         |
| `currents.registerMcpServer`     | `true`                        | Auto-register the Currents MCP server for AI agents                                         |


# Any MCP client

Connect any MCP client to the Currents MCP server with a sign-in or an API key, what a connection can reach, and the endpoint reference

This page is for MCP clients that the other [Connect your agent](https://docs.currents.dev/ai/connect) pages do not cover. It also covers API keys and what a connection can reach, for every client.

Currents hosts the MCP server at `https://mcp.currents.dev/mcp`. There is nothing to install. It is listed in the [MCP Registry](https://registry.modelcontextprotocol.io/v0.1/servers/dev.currents%2Fmcp/versions/latest) as `dev.currents/mcp`.

## Connect with a sign-in

Point the client at `https://mcp.currents.dev/mcp` and leave any client ID and secret empty. The first time the client calls Currents, you [sign in](https://docs.currents.dev/ai/connect#sign-in-once) in the browser. A client that can only register itself dynamically cannot connect this way; use an API key. Client developers: see [Endpoint reference](#endpoint-reference).

The connection acts as the person who signed in, in the organization they picked, with the permissions they approved. See [OAuth](https://docs.currents.dev/authentication/oauth).

## Connect with an API key

Use an API key when the client cannot complete the OAuth sign-in, or when no person is there to sign in, such as in CI. Send it in the `Authorization` header:

```json
{
  "mcpServers": {
    "currents": {
      "type": "http",
      "url": "https://mcp.currents.dev/mcp",
      "headers": {
        "Authorization": "Bearer your-api-key"
      }
    }
  }
}
```

A key acts as the organization, not as a person, and has one access level: **Read Only** or **Read & Write**. See [API Keys](https://docs.currents.dev/dashboard/administration/api-keys).

A connection made with a key is not listed under **Connected Applications**. Removing the server from the client does not end the key: it keeps working until an admin revokes it under **Organization → API Keys**.

## What a connection can reach

The server lists only the tools the connection's permissions allow, capped by the person's current role. It checks on every request. If a tool is missing, the connection lacks the permission; an agent that calls it by name is told the tool does not exist. [MCP tools and permissions](https://docs.currents.dev/ai/reference/mcp-server) lists the permission for each tool.

A **Read Only** API key gets the read tools, `currents-create-evidence-links` and the two Jira lookups (`currents-list-jira-projects` and `currents-list-jira-issue-types`). A **Read & Write** key gets every tool.

## Endpoint reference

For client developers. The client must use the Streamable HTTP transport of MCP and identify itself the way [For client developers](https://docs.currents.dev/authentication/oauth#for-client-developers) describes.

|                           |                                                                                 |
| ------------------------- | ------------------------------------------------------------------------------- |
| Endpoint                  | `https://mcp.currents.dev/mcp`                                                  |
| Method                    | `POST` only. `GET` and `DELETE` answer `405`                                    |
| Transport                 | Streamable HTTP, stateless, one exchange per request                            |
| Headers                   | `Content-Type: application/json`, `Accept: application/json, text/event-stream` |
| OAuth resource identifier | `https://mcp.currents.dev/mcp`                                                  |
| OAuth metadata document   | `https://mcp.currents.dev/.well-known/oauth-protected-resource/mcp`             |

The endpoint and the REST API are separate OAuth resource servers: a token for one is refused by the other. For the authorization server, PKCE and client identification, see [For client developers](https://docs.currents.dev/authentication/oauth#for-client-developers).

## Troubleshooting

The errors a client gets from the server. For errors in a specific agent, see its page under [Connect your agent](https://docs.currents.dev/ai/connect).

| Answer                                         | Cause                                                                                                    |
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `401` with a `WWW-Authenticate` header         | No credential, or an expired one. The header names the metadata document a client starts discovery from. |
| `403` `organization_not_enabled`               | The endpoint is not served to that organization. Contact <support@currents.dev>.                         |
| `405` with `Allow: POST`                       | The client opened a `GET` stream. This server is stateless and answers `POST` alone.                     |
| `406` or `415`                                 | A missing `Accept` or `Content-Type` header.                                                             |
| `does not support dynamic client registration` | The client can only register itself dynamically. Use an API key header instead.                          |

When a tool call fails, the server returns the status and response body to the agent, so the agent can tell why.


# Local MCP Server

Run the Currents MCP server on your own machine with the @currents/mcp package and an API key

The [`@currents/mcp`](https://github.com/currents-dev/currents-mcp) package runs the Currents MCP server on your machine, over `stdio`, with an API key. Use it only when your client cannot connect to the [hosted Currents MCP server](https://docs.currents.dev/ai/connect/remote), which needs nothing installed and signs each person in with their own role.

## Set it up

Create an [API key](https://docs.currents.dev/dashboard/administration/api-keys), then add this to your client's MCP configuration, for example `mcp.json` in Cursor or `claude_desktop_config.json` in Claude Desktop:

```json
{
  "mcpServers": {
    "currents": {
      "command": "npx",
      "args": ["-y", "@currents/mcp"],
      "env": {
        "CURRENTS_API_KEY": "your-api-key"
      }
    }
  }
}
```

The client downloads and starts the package. Then ask, for example: "Tests are failing in CI. Get the details for the last run on main and fix the failures."

## Permissions

The server can do only what the key allows. With a **Read Only** key, every write is refused with `403`. Use a Read Only key unless the agent needs to write.

The server lists every tool, whatever the key allows. [MCP tools and permissions](https://docs.currents.dev/ai/reference/mcp-server) lists them; the [repository README](https://github.com/currents-dev/currents-mcp) lists the tools in each version. With a **Read & Write** key, `currents-delete-run` and `currents-delete-webhook` delete without confirmation and cannot be undone.


# Reference

Reference for Currents share links, sessions, the trace API, and the MCP server tools and permissions

| Page                                                                           | What it covers                                                                                                                      |
| ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
| [Share links](https://docs.currents.dev/ai/reference/share-links)              | Fix links, Shared Runs, Shared Sessions, test, file and trace API links: what each one opens, who can open it and how long it lasts |
| [Sessions](https://docs.currents.dev/ai/reference/sessions)                    | What a session holds, its limits, and how to list and delete sessions                                                               |
| [Trace API](https://docs.currents.dev/ai/reference/trace-api)                  | Every route of the trace API, with its options and real output                                                                      |
| [MCP tools and permissions](https://docs.currents.dev/ai/reference/mcp-server) | The tools of the Currents MCP server and the permission each one needs                                                              |


# Share links

What a share link opens when you share a failing test, a run, a browser session, a file or a trace, who can open it, how long it lasts, and how to turn share links off

When you share a failing test, a CI run or a session an agent recorded, Currents creates a share link. Anyone who has the link can open it, without a Currents account, until it expires. A colleague, a reviewer or an agent then opens the results and files themselves. This page lists each kind of link, what it exposes, and how to turn share links off.

| Link           | What it opens                                                                                                                                                                     | Where you create it                                                                                                                                                                                                     | Lifetime                                              |
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| Fix link       | The failure context of a failing test or run, ready for an AI agent. See [Fix failing CI tests](https://docs.currents.dev/ai/agentic-testing/fix-failing-tests#share-a-fix-link). | **Share failure context** in the dashboard, **Fix with AI** in Slack, `currents run share --purpose fix` in the Currents CLI, or automatically in the GitHub comments                                                   | 1, 3 or 7 days; default 1                             |
| Shared Run     | Every test of a run, with links to its files. See [Share a CI run](https://docs.currents.dev/ai/agentic-testing/share-a-run).                                                     | **Share whole run** in the dashboard, `currents run share` in the Currents CLI, or ask an agent connected to the Currents MCP server                                                                                    | 1, 3 or 7 days; default 7                             |
| Shared Session | A [session an agent recorded](https://docs.currents.dev/ai/agent-evidence), with its files                                                                                        | `currents session share` in the Currents CLI, or ask an agent connected to the Currents MCP server                                                                                                                      | 1, 3 or 7 days; default 7                             |
| Test link      | One test of a Fix link or Shared Run, with its steps, files and traces                                                                                                            | Created with the Fix link or Shared Run, one for each test it lists                                                                                                                                                     | As long as that link                                  |
| File link      | One screenshot, video, log or trace zip                                                                                                                                           | Created with the link that lists the file. **Copy link** on a session file.                                                                                                                                             | As long as that link                                  |
| Trace API link | One Playwright trace, for an agent to read in steps. See [Explore a trace](https://docs.currents.dev/ai/agentic-artifacts/explore-a-trace).                                       | Created with the link that lists the trace, or alone by an agent connected to the Currents MCP server. See [Get a trace API link](https://docs.currents.dev/ai/agentic-artifacts/explore-a-trace#get-a-trace-api-link). | As long as that link; alone, 24 hours or up to 7 days |

A test link opens one test only, not the run it came from.

A Fix link, a Shared Run and their test links show the results as they were when the link was created. A Shared Session shows the session as it is now, including files added after the link was created.

Fix links, Shared Runs, Shared Sessions and test links also have a Markdown version for agents: add `.md` to the link. A trace API link has its own [routes for agents](https://docs.currents.dev/ai/reference/trace-api). To put these links in a pull request, Slack or Linear, see [Post evidence to GitHub, Slack and Linear](https://docs.currents.dev/ai/agentic-artifacts/post-evidence).

## What a link exposes

Everything the shared results contain: errors, stack traces, console and network logs, stdout and stderr, screenshots, videos and traces. A trace holds request bodies, headers and cookies.

Share a link only where you would post a public gist. Record sessions with test accounts, and do not print secrets in tests.

## Turn off share links

An organization admin can turn off **Public share links** in the AI section of the organization settings. New links then fail with `403`. Slack falls back to a prompt without a link. The GitHub comments link to the run or the test in Currents instead, with a prompt for an agent connected to the Currents MCP server. Links that already exist keep working until they expire. The setting does not apply to trace API links.

Each project's GitHub App settings also have **Add Fix Links to Comments** and **Fix Link Expiry**: whether the GitHub comments include Fix links, and how long they last. See [GitHub App](https://docs.currents.dev/resources/integrations/github/github-app#fix-links).

## Read limits

Public reads are rate limited per reader and per link. A link that many people open at once can answer `429` with a `Retry-After` header, even to a reader who opened it only a few times.


# Sessions

What a Currents session holds, which keys can create and read one, how to list and delete sessions with the API, and their limits

This page is the reference for sessions. To record one, start at [Agent evidence](https://docs.currents.dev/ai/agent-evidence).

A session is one recording that an agent or a person saved to Currents: the files of a task, such as screenshots, videos, Playwright traces and logs, with a title and a status.

A session holds:

* A title, a passed or failed status, an error, and tags
* The commit, branch and pull request
* The files

A session is not a test run. It has no spec files or tests, and it does not appear in run lists, analytics or flakiness.

## Create a session

| From                                          | Use                                                                                                                                             |
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| A shell                                       | The Currents CLI: [`currents session start`, `attach` and `share`](https://docs.currents.dev/resources/reporters/currents-cmd/currents-session) |
| An agent connected to the Currents MCP server | The Currents MCP tools. See [Record without the Currents CLI](https://docs.currents.dev/ai/agent-evidence/mcp-tools).                           |
| A script                                      | The [Sessions API](https://docs.currents.dev/api/resources/sessions)                                                                            |

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-9df1ba8bfdac07439c1c458f2b061e50633c41bb%2Fterminal-session-cli.gif?alt=media" alt="A terminal: currents session start, attach with a folder of evidence, and share, which prints the session link and its Markdown link"><figcaption></figcaption></figure>

## Keys

| Key                                                                                 | Can                                                                                                                  |
| ----------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| [Record key](https://docs.currents.dev/guides/record-key)                           | Create a session, attach files, and share it                                                                         |
| Read & Write [API key](https://docs.currents.dev/dashboard/administration/api-keys) | Everything: create, attach, share, list, read and delete                                                             |
| Read Only API key                                                                   | List and read sessions, and create [trace API links](https://docs.currents.dev/ai/agentic-artifacts/explore-a-trace) |

## List and delete sessions

The dashboard has no list of sessions. Use the API:

* `GET /v1/projects/:projectId/sessions` lists a project's sessions, newest first. It filters by branch, tag, pull request, date and text, as the run list does.
* `DELETE /v1/sessions/:sessionId` deletes a session, its files and its links.

## Limits

* A session holds up to 200 files, of up to 1 GiB each.
* A [session link](https://docs.currents.dev/ai/reference/share-links) lasts 1, 3 or 7 days, 7 by default. A link posted in a pull request stops working after that; share the session again for a new link. See [Share links](https://docs.currents.dev/ai/reference/share-links).
* The files stay until you delete the session, within your plan's [data retention](https://docs.currents.dev/resources/data-privacy/data-retention).
* A trace holds request bodies, headers and cookies, and anyone with the link can read them. Record with test accounts.
* Anyone who has your record key can create sessions and share links in your organization. Keep it in your CI secrets, as you do for runs.
* Self-hosted Currents has no trace API, so the session page has no trace player there.


# Trace API

Every route of the Currents trace API, with its options and real output: the trace summary, the player, screen frames, filmstrips and animations, the page at any time in five formats, network requests

The trace API lets an agent read a Playwright trace one part at a time. Each trace has its own trace API link. Add a path to the link to get one part of the trace: the summary, the page at a moment, a network request, or an image. This page lists every route with its options and real output. For how an agent uses the trace API, see [Explore a trace](https://docs.currents.dev/ai/agentic-artifacts/explore-a-trace).

## Get a trace API link from a script

The REST API needs an API key with `results:read`; a Read Only key is enough. To get a link for a test from a script, use the IDs in the test's dashboard link, `/instance/<instanceId>/test/<testId>`. `ttlSeconds` sets how long the link lasts:

```bash
curl -X POST https://api.currents.dev/v1/instances/$INSTANCE_ID/trace-link \
  -H "Authorization: Bearer $CURRENTS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"testId": "'$TEST_ID'", "ttlSeconds": 604800}'
```

The response has the trace API link in `data.url` and its expiry time in `data.expiresAt`. For a trace in a session, use `POST /v1/sessions/{sessionId}/attachments/{attachmentId}/trace-link`.

For who can open a trace API link and how long it lasts, see [Share links](https://docs.currents.dev/ai/reference/share-links).

## Routes

Every route is a `GET` on the trace API link. The full specification is at [t.crts.sh/docs](https://t.crts.sh/docs), and as OpenAPI at [t.crts.sh/openapi.json](https://t.crts.sh/openapi.json).

| Route                                                                                                             | Returns                                                                                                                    |
| ----------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| [`/digest`](#summary)                                                                                             | The summary: the actions with their times, the failed action, page errors, console errors and failed requests. Start here. |
| [No path](#player)                                                                                                | A player for people: the screencast, the actions and the frames                                                            |
| [`/frames`, `/frames/failure`, `/frames/{t}`](#screen-frames)                                                     | The list of screen frames, or one frame as an image                                                                        |
| [`/filmstrip`](#filmstrip)                                                                                        | Frames from the whole recording in one image                                                                               |
| [`/animation`](#animation)                                                                                        | The recording as an animated image                                                                                         |
| [`/snapshots`, `/snapshots/failure`, `/snapshots/{id}`](#page-snapshots)                                          | The list of page snapshots, or the page at one moment in five formats                                                      |
| [`/requests`, `/requests/{index}`, `/requests/{index}/body`, `/requests/{index}/request-body`](#network-requests) | The network requests, one request, and its bodies                                                                          |
| [`/attachments`, `/attachments/{id}`](#attachments)                                                               | The files the test saved in the trace                                                                                      |
| [`/download`](#trace-zip)                                                                                         | The trace zip                                                                                                              |

Times (`t`) are milliseconds from the start of the trace; the summary gives the time of each action. A route that takes `t` returns the frame or snapshot at or before that time.

The examples on this page come from two traces. Each example says which:

* A failed test, `SAVE10 takes 10% off the total`. The test expected a total of `$206.55` and got `$183.60`.
* The checkout session from [Explore a trace](https://docs.currents.dev/ai/agentic-artifacts/explore-a-trace#example-a-checkout-that-freezes), where the **Apply** button stays on `Applying…`. Nothing in it failed, but the page threw a `TypeError`.

## Summary

| Route     | Returns                                                                                                                                                 |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `/digest` | The actions with their times, the failed action and its error, page errors, console errors, failed requests, the files in the trace, and the screencast |

| Parameter  | Values                                                                                                  |
| ---------- | ------------------------------------------------------------------------------------------------------- |
| `format`   | `json` (default) or `md`                                                                                |
| `timeline` | `auto` (default) keeps the actions near the failure and leaves out the rest. `full` lists every action. |

`/digest?format=md` is the first call. It names the failed action and its error, links to the screen and the page at the failure, and lists the actions with their times.

{% tabs %}
{% tab title="md" %}
`/digest?format=md`, the failed test, shortened:

```markdown
28 actions, 1 failed · browser: chromium · Playwright 1.63.0 · 8 network requests · 3 screencast frames

## Failing actions

### Expect "toHaveText" — `#total`

Expected: "$206.55"
Received: "$183.60"

at t=1741ms, duration 3005ms · [frame at failure](./frames/1803) · [page text at failure](./snapshots/4746?format=text) · [styled page at failure](./snapshots/4746?format=html)

## Action timeline

- · t=1649 Navigate / (32ms)
- · t=1682 Fill "save10" `internal:label="Discount code"i` (20ms)
- · t=1703 Click `internal:role=button[name="Apply"i]` (37ms)
- ✗ t=1741 Expect "toHaveText" `#total` (3005ms)
```

{% endtab %}

{% tab title="json" %}
`/digest`, the checkout session, shortened:

```json
{
  "browserName": "chromium",
  "playwrightVersion": "1.64.0-alpha-1790635538000",
  "actionCount": 9,
  "failedActionCount": 0,
  "actions": [
    { "callId": "kiwx@17", "title": "Frame.click", "startTime": 2429.996, "endTime": 2463.014, "durationMs": 33,
      "error": null, "selector": "internal:role=button[name=\"Apply\"i]" }
  ],
  "pageErrors": [
    { "name": "TypeError", "message": "Cannot destructure property 'percent' of 'DISCOUNT_CODES[code]' as it is undefined.",
      "location": "http://localhost:4183/app.js:39", "time": 2462.509 }
  ],
  "consoleErrors": [
    { "messageType": "error", "text": "Failed to load resource: the server responded with a status of 404 (Not Found)",
      "time": 665.779, "location": "http://localhost:4183/favicon.ico:0" }
  ],
  "networkFailures": [],
  "networkRequestCount": 3,
  "attachments": [],
  "screencast": { "frameCount": 12, "startTimestamp": 678.073, "endTimestamp": 3981.393 }
}
```

{% endtab %}
{% endtabs %}

## Player

| Route   | Returns                                                                                                                |
| ------- | ---------------------------------------------------------------------------------------------------------------------- |
| No path | A page for people: the screencast, the actions with their times, the frames, and a link to the Playwright Trace Viewer |

The checkout session:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-41d610218fd11a67791b76b1e86f94e6c7247dc2%2Ftrace-player-checkout.png?alt=media" alt="The trace API player: the screencast of the checkout with a play button and frame thumbnails, and the list of 9 actions with their times, 0 failed, 3 requests"><figcaption><p>The trace API link without a path: the checkout session in the player</p></figcaption></figure>

## Screen frames

| Route             | Returns                                                              |
| ----------------- | -------------------------------------------------------------------- |
| `/frames`         | The list of screen frames, with the time of each                     |
| `/frames/failure` | The frame when the test failed. When nothing failed, the last frame. |
| `/frames/{t}`     | The frame at or before time `t`                                      |

| Parameter     | Values                                                             |
| ------------- | ------------------------------------------------------------------ |
| `format`      | `jpeg` (default) or `webp`                                         |
| `width`       | 16 to 3840: a WebP of this width                                   |
| `placeholder` | `1`, on `/frames/failure` only. See [Placeholders](#placeholders). |

| Response header     | Value                                                                                                                   |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `x-trace-timestamp` | The time of the frame returned                                                                                          |
| `content-location`  | The time of the frame returned, as a path next to the one asked for                                                     |
| `x-dashboard-url`   | On `/frames`: the test's page in the Currents dashboard, when the link names a test. Opening it needs a Currents login. |

`/frames`, the checkout session, shortened:

```json
{
  "playwrightVersion": "1.64.0-alpha-1790635538000",
  "traceFormatVersion": 10,
  "frameCount": 12,
  "startTimestamp": 678.073,
  "endTimestamp": 3981.393,
  "width": 1000,
  "height": 560,
  "frames": [{ "timestamp": 678.073, "width": 1000, "height": 560 }, { "timestamp": 678.638, "width": 1000, "height": 560 }]
}
```

`/frames/2464` in the checkout session returns the frame from before that time, and says which in its headers:

```http
content-type: image/jpeg
content-location: 2410.593
x-trace-timestamp: 2410.593
```

`/frames/failure`, the failed test:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-e36d60b697474afcffa288449c01e52c97539160%2Ftrace-frame-failure.png?alt=media" alt="The checkout at the failure: SAVE10 applied, a discount of −$22.95 and a total of $183.60" width="584"><figcaption><p><code>/frames/failure</code>: the screen when the test failed</p></figcaption></figure>

## Filmstrip

| Route        | Returns                                           |
| ------------ | ------------------------------------------------- |
| `/filmstrip` | Frames from the whole recording in one WebP image |

| Parameter     | Values                                                                                                                                                                    |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `frames`      | 2 to 25. Default 9.                                                                                                                                                       |
| `width`       | The width of each frame, 64 to 1280. Default 320.                                                                                                                         |
| `height`      | The largest height of each frame, 16 to 1280                                                                                                                              |
| `layout`      | `grid` (default) or `row`                                                                                                                                                 |
| `end`         | `failure`: stop at the frame `/frames/failure` returns, the last one before the failure, and outline it in red. When nothing failed, the whole recording with no outline. |
| `placeholder` | `1`. See [Placeholders](#placeholders).                                                                                                                                   |

| Response header          | Value                                                  |
| ------------------------ | ------------------------------------------------------ |
| `x-filmstrip-timestamps` | The time of each frame, such as `[678,1787,2498,3981]` |

`/filmstrip?frames=4&width=640`, the checkout session:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-d7b04a14498e569395b184725fabfcd2a90295e7%2Ftrace-filmstrip-checkout.png?alt=media" alt="Four frames of the checkout in a grid: the empty discount field, save10 being typed, then twice the Apply button greyed out as Applying… with the total unchanged at $229.50"><figcaption><p><code>/filmstrip?frames=4&#x26;width=640</code>: four frames of the checkout session</p></figcaption></figure>

`/filmstrip?end=failure&layout=row&width=480`, the failed test. The trace has three frames up to the failure, and the last one has a red outline:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-1c054fd9bca5de62102d44868e3e3384c0e3cb6d%2Ftrace-filmstrip-failure-row.png?alt=media" alt="Three frames of the checkout in one row: save10 typed into the discount field with a total of $229.50, then the same, then outlined in red: SAVE10 applied: 10% off, a discount of −$22.95 and a total of $183.60"><figcaption><p><code>/filmstrip?end=failure&#x26;layout=row&#x26;width=480</code>: the failed test up to the failure</p></figcaption></figure>

## Animation

| Route        | Returns                            |
| ------------ | ---------------------------------- |
| `/animation` | The recording as an animated image |

| Parameter | Values                                                                                       |
| --------- | -------------------------------------------------------------------------------------------- |
| `format`  | `webp` (default) or `gif`                                                                    |
| `frames`  | 1 to 150. Default 60. A trace with fewer frames gives fewer.                                 |
| `width`   | The largest width, 16 to 2560. Default 720.                                                  |
| `quality` | The quality of a WebP, 1 to 100. Default 75.                                                 |
| `overlay` | `progress`: draw the frame number, such as `11/12`, in the bottom right corner of each frame |

| Response header             | Value                       |
| --------------------------- | --------------------------- |
| `x-animation-frames`        | The frames in the animation |
| `x-animation-source-frames` | The frames in the trace     |

`/animation?overlay=progress&width=640`, the checkout session. The trace has 12 frames, so `x-animation-frames` and `x-animation-source-frames` are both `12`:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-cc1a7850bb44fe12e835824c2f924c20ad02fb55%2Ftrace-animation-progress.webp?alt=media" alt="An animation of the checkout with the frame number in the bottom right corner: save10 is typed into the discount field, Apply is clicked, and the button stays on Applying… while the total stays at $229.50" width="584"><figcaption><p><code>/animation?overlay=progress&#x26;width=640</code>: the checkout session as a WebP, with the frame number</p></figcaption></figure>

## Page snapshots

| Route                | Returns                                                                           |
| -------------------- | --------------------------------------------------------------------------------- |
| `/snapshots`         | The list of page snapshots, with the time of each                                 |
| `/snapshots/failure` | The page when the test failed. When nothing failed, the last snapshot.            |
| `/snapshots/{id}`    | One snapshot. `{id}` is a time, or a name from the list when the trace has names. |

| Parameter     | Values                                                                                                    |
| ------------- | --------------------------------------------------------------------------------------------------------- |
| `format`      | `json` (default): the snapshot's entry and the formats it has. `text`, `aria`, `dom` or `html`: the page. |
| `placeholder` | `1`, on `/snapshots/failure?format=html` only. See [Placeholders](#placeholders).                         |

| Response header     | Value                                                                                      |
| ------------------- | ------------------------------------------------------------------------------------------ |
| `x-trace-timestamp` | The time of the snapshot returned                                                          |
| `content-location`  | The snapshot returned, as a path next to the one asked for, such as `2463.971?format=text` |

`/snapshots`, the checkout session, shortened. `callId` is the action in the summary that took the snapshot:

```json
[
  { "t": 2430.515, "name": null, "phase": null, "callId": "kiwx@17", "frameUrl": "http://localhost:4183/" },
  { "t": 2463.434, "name": null, "phase": null, "callId": "kiwx@17", "frameUrl": "http://localhost:4183/" },
  { "t": 2463.971, "name": null, "phase": null, "callId": "kiwx@19", "frameUrl": "http://localhost:4183/" }
]
```

`/snapshots/2464`, the checkout session:

```json
{ "t": 2463.971, "name": null, "phase": null, "callId": "kiwx@19", "frameUrl": "http://localhost:4183/", "formats": ["json", "dom", "html", "aria", "text"] }
```

The four page formats, from the failed test:

{% tabs %}
{% tab title="text" %}
`/snapshots/failure?format=text` returns the page text, with input values and buttons:

```
Discount code
<input value="save10" placeholder="e.g. SAVE10">
<button>
Apply
SAVE10 applied: 10% off
Subtotal
$229.50
Discount
−$22.95
Total
$183.60
```

{% endtab %}

{% tab title="aria" %}
`/snapshots/failure?format=aria` returns the accessibility tree, in the format of Playwright's `ariaSnapshot()`. Roles and names come from the HTML only, so an element that a stylesheet hides still shows:

```yaml
- form
  - textbox "Discount code": save10
  - button "Apply"
  - status
    - text: SAVE10 applied: 10% off
- text: Total
- text: $183.60
- button "Pay now"
```

{% endtab %}

{% tab title="dom" %}
`/snapshots/failure?format=dom` returns the HTML of the page as plain text, to search or compare. Part of it:

```html
<DT>Discount</DT>
<DD id="discount">−$22.95</DD>
<DT>Total</DT>
<DD id="total">$183.60</DD>
```

{% endtab %}

{% tab title="html" %}
`/snapshots/failure?format=html` returns a page that a browser opens with the styles from the trace. The trace API removes the scripts, so buttons and links do nothing. Opened in a browser:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-740437e4360149b9cd165dedd62c84370446ebed%2Ftrace-snapshot-html.png?alt=media" alt="The checkout page rebuilt from the DOM snapshot at the failure: save10 in the discount field, SAVE10 applied: 10% off, a discount of −$22.95 and a total of $183.60"><figcaption><p><code>/snapshots/failure?format=html</code>: the page when the test failed, opened in a browser</p></figcaption></figure>
{% endtab %}
{% endtabs %}

## Network requests

| Route                            | Returns                      |
| -------------------------------- | ---------------------------- |
| `/requests`                      | The requests the page made   |
| `/requests/{index}`              | One request                  |
| `/requests/{index}/body`         | The body the server returned |
| `/requests/{index}/request-body` | The body the page sent       |

| Parameter     | Values                                                                                                                                                                                                      |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `status`      | `4xx`, `5xx`, `failed`, or a status code such as `404`. `failed` is a request that got no response, or a 4xx or 5xx response.                                                                               |
| `url`         | Text that the URL contains                                                                                                                                                                                  |
| `requestBody` | Text that the body the page sent contains, such as a GraphQL operation name. Up to 1000 characters. When the bodies to search are over 32 MB together, it returns 422: filter with `url` or `status` first. |
| `format`      | `json` (default) or `har`: a HAR 1.2 file without bodies, which opens in the browser's developer tools                                                                                                      |

`/requests?url=app.js`, the checkout session:

```json
[{ "index": 2, "method": "GET", "url": "http://localhost:4183/app.js", "status": 200, "statusText": "OK",
   "mimeType": "application/javascript; charset=UTF-8", "bodySize": -1, "bodySha1": null, "requestBodySha1": null,
   "startedDateTime": "2026-10-09T06:15:53.396Z", "durationMs": 6.015, "monotonicTime": 647.048 }]
```

`/requests/2` returns the same request as one object. `bodySha1` is `null` because the trace has no body for this response, so `/requests/2/body` returns 404.

In the failed test, every GraphQL call goes to the same `/graphql` URL, so `/requests?requestBody=ApplyDiscount` finds the call by the operation name it sent:

```json
[{ "index": 7, "method": "POST", "url": "http://127.0.0.1:4197/graphql", "status": 200, ... }]
```

Then `/requests/7/request-body` and `/requests/7/body`:

```json
{"query": "mutation ApplyDiscount($code: String!) { applyDiscount(code: $code) { code percent discount total } }", "variables": {"code": "save10"}}
{"data": {"applyDiscount": {"code": "SAVE10", "percent": 10, "discount": 2295, "total": 18360}}}
```

The server sent a total of `18360` cents: the subtotal minus the discount, twice. The bug is in the server, not in the page.

`/requests?format=har`, the checkout session, shortened:

```json
{
  "log": {
    "version": "1.2",
    "creator": { "name": "currents-trace-api", "version": "1" },
    "entries": [
      {
        "startedDateTime": "2026-10-09T06:15:53.388Z",
        "time": 5.533,
        "request": { "method": "GET", "url": "http://localhost:4183/", "httpVersion": "HTTP/1.1", "headers": [{ "name": "Host", "value": "localhost:4183" }] }
      }
    ]
  }
}
```

A wrong `status` returns 400 with the values it takes: `{"error":"status must be 4xx, 5xx, failed, or a 3-digit code"}`.

## Attachments

| Route               | Returns                                                                                                                                          |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `/attachments`      | The files the test saved in the trace, such as the video, the screenshot and `error-context`, with the name, content type and SHA-1 hash of each |
| `/attachments/{id}` | One file, by its hash or its name, with the file's own content type                                                                              |

| Parameter | Values                                                                                 |
| --------- | -------------------------------------------------------------------------------------- |
| `name`    | On `/attachments`: text that the file name contains, such as `/attachments?name=error` |

| Response header                          | Value                                                                    |
| ---------------------------------------- | ------------------------------------------------------------------------ |
| `x-attachment-name`, `x-attachment-sha1` | On `/attachments/{id}`: the name and the SHA-1 hash of the file returned |

A retry can save a file with the same name again, so a name returns the last file with that name.

`/attachments`, the failed test. `callId` is the step that saved the file:

```json
[
  { "name": "video", "contentType": "video/webm", "sha1": "7f4c1aa21fc4f772f8392b90f1b2d8fffd6eeeeb",
    "file": "attachments/7f4c1aa21fc4f772f8392b90f1b2d8fffd6eeeeb", "callId": "fixture@45" },
  { "name": "error-context", "contentType": "text/markdown", "sha1": "1aeff453f814f2d988212f6cb6e0ee5d63f0c26f",
    "file": "attachments/1aeff453f814f2d988212f6cb6e0ee5d63f0c26f", "callId": "attach@a0bd6f912f21848fc9fc6fe2c64c4611" },
  { "name": "screenshot", "contentType": "image/png", "sha1": "a8fae78a7904ebca24b0a25ec23903eab7a3a4dc",
    "file": "attachments/a8fae78a7904ebca24b0a25ec23903eab7a3a4dc", "callId": "hook@43" }
]
```

`/attachments/error-context` is the failure summary that Playwright writes for an agent: the test name, the error, the element at the failure as an accessibility tree, and the test source. The failed test, shortened:

````markdown
# Test info

- Name: checkout.spec.ts >> SAVE10 takes 10% off the total
- Location: tests/checkout.spec.ts:23:1

# Error details

```
Error: expect(locator).toHaveText(expected) failed

Locator:  locator('#total')
Expected: "$206.55"
Received: "$183.60"
```

```yaml
- definition: $183.60
```

# Test source

```ts
  23 | test("SAVE10 takes 10% off the total", async ({ page }) => {
  24 |   await page.getByLabel("Discount code").fill("save10");
  25 |   await page.getByRole("button", { name: "Apply" }).click();
> 26 |   await expect(page.locator("#total")).toHaveText("$206.55");
     |                                        ^ Error: expect(locator).toHaveText(expected) failed
```
````

The checkout session has no files, so its `/attachments` returns `[]`.

## Trace zip

| Route       | Returns                       |
| ----------- | ----------------------------- |
| `/download` | The trace zip, as `trace.zip` |

To open it in Playwright's trace viewer, give the viewer the link: `https://trace.playwright.dev/?trace=<trace API link>/download`.

## Placeholders

`/filmstrip`, `/frames/failure` and `/snapshots/failure?format=html` take `placeholder=1`. With it, they return a grey image or a short page with status 200 instead of an error. Use it for images in a pull request comment, so that they do not break after the link expires.

| Response header | Value                                                                                                                                                                                                                 |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `x-placeholder` | Why a placeholder was returned. `notFound`: the link is wrong or expired. `routeError`: the trace has nothing to show, such as no screen frames, or a parameter is wrong. `unavailable`: the trace could not be read. |

A filmstrip of an expired link, `/filmstrip?placeholder=1&width=640`:

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-d8d302619a41673f2c3b450a25bcd4cd6a9c79d2%2Ftrace-placeholder-expired.svg?alt=media" alt="A grey box with the text This link has expired" width="584"><figcaption><p><code>/filmstrip?placeholder=1&#x26;width=640</code> after the link expires</p></figcaption></figure>


# MCP tools and permissions

Every tool of the Currents MCP server, what it does and the permission it needs, and how the hosted and local servers differ

The Currents MCP server gives an agent these tools. Each tool needs one permission. A connection to the [hosted server](https://docs.currents.dev/ai/connect/remote) lists only the tools its permissions cover. The [local server](https://docs.currents.dev/ai/connect/local) lists every tool, and the API key refuses what it does not allow.

To set up an agent, see [Connect your agent](https://docs.currents.dev/ai/connect).

## Tools

| Tool                                    | What it does                                                                                                                     | Permission       |
| --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------- |
| `currents-get-projects`                 | Lists the projects                                                                                                               | `projects:read`  |
| `currents-get-project`                  | Gets one project and its settings                                                                                                | `projects:read`  |
| `currents-list-project-terms`           | Lists the tags, branches, authors and other values in a project's runs                                                           | `projects:read`  |
| `currents-get-runs`                     | Lists a project's runs, filtered by branch, tag, status, date or text                                                            | `results:read`   |
| `currents-get-run-details`              | Gets one run: its status, commit, branch, groups and spec files                                                                  | `results:read`   |
| `currents-find-run`                     | Finds the latest completed run by CI build ID, branch or tags                                                                    | `results:read`   |
| `currents-get-spec-instance`            | Gets the raw result of one spec file execution                                                                                   | `results:read`   |
| `currents-get-test-results`             | Gets the history of one test                                                                                                     | `results:read`   |
| `currents-get-context`                  | Gets why tests failed: the errors, steps and files of a run, a spec file or a test                                               | `results:read`   |
| `currents-get-test-evidence`            | Lists the screenshots, videos, traces and attachments of each test in a CI run                                                   | `results:read`   |
| `currents-create-evidence-links`        | Creates a [trace API link](https://docs.currents.dev/ai/agentic-artifacts/explore-a-trace) for a test attempt or a session trace | `results:read`   |
| `currents-list-pull-requests`           | Lists a project's pull requests with their runs                                                                                  | `results:read`   |
| `currents-get-project-insights`         | Gets run and test metrics for a project over time                                                                                | `analytics:read` |
| `currents-get-spec-files-performance`   | Ranks spec files by duration, failures or flakiness                                                                              | `analytics:read` |
| `currents-get-tests-performance`        | Ranks tests by failures, flakiness or duration                                                                                   | `analytics:read` |
| `currents-get-errors-explorer`          | Groups and counts errors across runs                                                                                             | `analytics:read` |
| `currents-list-actions`                 | Lists the actions: rules that skip, quarantine or tag tests                                                                      | `actions:read`   |
| `currents-get-action`                   | Gets one action and its conditions                                                                                               | `actions:read`   |
| `currents-list-affected-tests`          | Lists the tests that actions applied to                                                                                          | `actions:read`   |
| `currents-get-affected-test-executions` | Lists the executions of one test that an action applied to                                                                       | `actions:read`   |
| `currents-get-action-executions`        | Lists the test executions that one action applied to                                                                             | `actions:read`   |
| `currents-create-action`                | Creates an action                                                                                                                | `actions:write`  |
| `currents-update-action`                | Changes an action                                                                                                                | `actions:write`  |
| `currents-delete-action`                | Archives an action                                                                                                               | `actions:write`  |
| `currents-enable-action`                | Turns an action on                                                                                                               | `actions:write`  |
| `currents-disable-action`               | Turns an action off                                                                                                              | `actions:write`  |
| `currents-create-session`               | Creates a [session](https://docs.currents.dev/ai/reference/sessions) and returns upload URLs for its files                       | `runs:write`     |
| `currents-add-attachments`              | Adds files to a session or a CI run                                                                                              | `runs:write`     |
| `currents-cancel-run`                   | Cancels a run in progress                                                                                                        | `runs:write`     |
| `currents-cancel-run-github-ci`         | Cancels the run of a GitHub Actions workflow run                                                                                 | `runs:write`     |
| `currents-reset-run`                    | Resets the failed spec files of a run so they run again                                                                          | `runs:write`     |
| `currents-delete-run`                   | Deletes a run and all its data, permanently                                                                                      | `runs:write`     |
| `currents-create-share-link`            | Creates a public [share link](https://docs.currents.dev/ai/reference/share-links) to a run, a spec file, a test or a session     | `shares:write`   |
| `currents-list-webhooks`                | Lists a project's webhooks                                                                                                       | `webhooks:read`  |
| `currents-get-webhook`                  | Gets one webhook                                                                                                                 | `webhooks:read`  |
| `currents-create-webhook`               | Creates a webhook that sends run events to a URL                                                                                 | `webhooks:write` |
| `currents-update-webhook`               | Changes a webhook                                                                                                                | `webhooks:write` |
| `currents-delete-webhook`               | Deletes a webhook, permanently                                                                                                   | `webhooks:write` |
| `currents-list-jira-projects`           | Lists the projects in your connected Jira                                                                                        | `issues:write`   |
| `currents-list-jira-issue-types`        | Lists the issue types and fields of a Jira project                                                                               | `issues:write`   |
| `currents-create-jira-issue`            | Creates a Jira issue for a test in a run                                                                                         | `issues:write`   |
| `currents-link-jira-issue`              | Links an existing Jira issue to a test in a run                                                                                  | `issues:write`   |
| `currents-get-tests-signatures`         | Computes the ID Currents gives a test from the project, spec file path and test title. Reads no data.                            | Every connection |

## Tools to grant with care

* `currents-delete-run` and `currents-delete-webhook` cannot be undone, and Currents does not ask for confirmation. Grant `runs:write`, `webhooks:write` or a **Read & Write** key only to an agent that needs them.
* Some tools reach beyond Currents. The Jira tools read and write issues in your connected Jira. The webhook tools store a URL that Currents later sends run data to. `currents-create-share-link` creates a link that anyone can open.

The server also gives a connected agent [skills](https://docs.currents.dev/ai/agent-skills/agent-skill-currents-mcp): the steps an agent follows for a task.

## Hosted or local

[MCP](https://modelcontextprotocol.io/introduction) (Model Context Protocol) is an open standard for giving an AI agent tools. Currents serves the same tools two ways:

|               | [Hosted](https://docs.currents.dev/ai/connect/remote) | [Local](https://docs.currents.dev/ai/connect/local) |
| ------------- | ----------------------------------------------------- | --------------------------------------------------- |
| Address       | `https://mcp.currents.dev/mcp`                        | The `@currents/mcp` npm package                     |
| Runs          | Hosted by Currents                                    | On your machine                                     |
| Credentials   | A sign-in, or an API key                              | API key only                                        |
| Acts as       | The person who signed in, in one organization         | The organization the key belongs to                 |
| Tool list     | The tools the connection was granted                  | Every tool                                          |
| Stays current | Ships with Currents                                   | Fetched again by the client on each start           |

Use the hosted server unless your client can only start local servers. It needs nothing installed, and a sign-in gives each person access that follows their own role, which an admin can revoke without changing a shared key.


# Record Key

Using record key to associate your runs with your organization

### What is Record Key?

Record key is a secret you use to associate runs with your organization in Currents dashboard.

When running tests in parallel using Currents dashboard, provide your Record Key as `--key` argument.

### Can I publish my Record Key?

You'd treat your Record Key as a secret and not publish it. Having your Record Key would allow creating new runs on behalf of your organization.

### Where is my Record Key?

You can obtain your record key by navigating to "Record Keys" section of your organization menu. Accessed by clicking on your Organization's Name in the side menu.

<div data-with-frame="true"><figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FVFoI0z7pnXxOKAxweeD5%2FScreenshot%202026-09-22%20at%2010.58.20.png?alt=media&amp;token=32392492-1f66-4426-b9f7-69d82bcd6778" alt="Record Keys for Currents Dashboard"><figcaption><p>Record Keys for Currents Dashboard</p></figcaption></figure></div>

### Can I record without storing a Record Key?

Yes. A CI job can use the OIDC token from GitHub Actions, GitLab CI, CircleCI, Buildkite or Bitbucket Pipelines instead. See [Record from CI with an OIDC token instead of a record key](https://docs.currents.dev/guides/record-key/record-from-ci-with-oidc).

### Can I rotate my Record Key?

Yes, in "Record Keys" section of your organization menu, delete the existing key and create a new key.

<div data-with-frame="true"><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2F1JLJvUt09lgtYIQwnFwB%2Fcurrents-rotate-record-key.png?alt=media&amp;token=c3890165-fbed-434e-84da-b6663e6582a6" alt="Rotating a record key"></div>

{% hint style="info" %}
Please note: requests to create a run for non-existing or deleted Record Key will be rejected
{% endhint %}


# Record from CI with OIDC

Record test runs to Currents from GitHub Actions, GitLab.com, CircleCI, Buildkite or Bitbucket Pipelines without storing a record key, using the CI provider's OIDC token

A CI job can record runs to Currents without a stored record key. The reporter exchanges the job's OIDC token (OpenID Connect identity token) for a short-lived record key. There is no record key to store in CI secrets and none to rotate.

The exchange follows OAuth 2.0 Token Exchange ([RFC 8693](https://datatracker.ietf.org/doc/html/rfc8693)), and the revoke follows OAuth 2.0 Token Revocation ([RFC 7009](https://datatracker.ietf.org/doc/html/rfc7009)).

## Prerequisites

* A Currents project and its project ID. See [Quick Start](https://docs.currents.dev/getting-started/your-first-playwright-run).
* Organization admin access, to create a trust policy.
* A CI provider that Currents accepts: GitHub Actions, GitLab.com, CircleCI, Buildkite or Bitbucket Pipelines. A self-hosted Currents can also accept self-managed GitLab and GitHub Enterprise Server, see [Self-hosted Currents](#self-hosted-currents).
* One of these clients:
  * `@currents/playwright` 2.8.0 or later
  * `@currents/cmd` 3.1.0 or later, for the commands that take a record key. Commands that take only an API key still need one, see [Credentials](https://docs.currents.dev/resources/reporters/currents-cmd#credentials).
  * [`cancel-run-gh-action`](#cancel-run-gh-action) 1.2.0 or later (`@v1`)
  * [`playwright-last-failed`](#playwright-last-failed) 2.2.0 or later (`@v2`)

## Create a trust policy

A trust policy tells Currents which CI jobs may get a record key for your organization. It names a CI provider and an owner, such as a GitHub organization, and optionally one project of that owner.

{% stepper %}
{% step %}
In the organization menu of the dashboard, open **API & Record Keys**, then the **OIDC trust policies** section. Only organization admins see the section.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-33e7305dd26d356e343b8052d49e30833b8e8955%2Foidc-trust-policies-section.png?alt=media" alt="The OIDC trust policies section of API &#x26; Record Keys: a Create trust policy button, and a list of trusted owners and projects with their CI provider, two of them marked Never used" width="720"><figcaption></figcaption></figure>
{% endstep %}

{% step %}
Select **Create trust policy**, and pick the **CI provider**: GitHub, GitLab.com, CircleCI, Buildkite or Bitbucket.

On a self-hosted Currents that lists self-managed instances, a **Server** menu appears for GitHub and GitLab. Pick `github.com`, `gitlab.com` or the host of the instance.
{% endstep %}

{% step %}
Enter the owner. To limit the policy to one project, also enter the project. Leave the project empty to trust every project of the owner.

* GitHub: enter **GitHub organization or user** and **Repository (optional)** by name. Currents looks them up on GitHub, and finds public repositories only. For a private repository, select **Enter the IDs myself (private repositories)** and enter the **Owner ID** (`repository_owner_id`) and, if you named a repository, the **Repository ID** (`repository_id`). The help under each field shows the `gh api` command that prints the ID.
* GitHub Enterprise Server: enter **GitHub owner ID** and **GitHub repository ID (optional)**.
* GitLab.com, CircleCI, Buildkite and Bitbucket: enter the IDs. The help under each field says where to find them. **Owner name** and **Project name** are optional and only label the policy in the list.
  {% endstep %}

{% step %}
Optional: enter **Maximum token age (minutes)**, a whole number from 1 to 1440. Currents then refuses a token issued longer ago than this, counted from the `iat` claim of the token. A short limit reduces how long a token that leaks from a job log stays useful. Leave the field empty for no limit.
{% endstep %}

{% step %}
Select **Create**.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-c670c18d67d4f0dad6fed2cecf22469dee2bcc7b%2Foidc-create-trust-policy-dialog.png?alt=media" alt="The Create trust policy dialog for GitHub, with the organization acme and the repository web entered, the Enter the IDs myself checkbox, an empty Maximum token age field, and the Create button" width="560"><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

Organization admins get an email when a policy is created or removed.

### Which IDs Currents matches

Currents matches the IDs that the CI provider puts in the token, not the names. A renamed repository keeps its ID and still matches. A new repository created under an old name has a new ID and does not match.

| CI provider         | Owner                       | Project (optional) | IDs are |
| ------------------- | --------------------------- | ------------------ | ------- |
| GitHub Actions      | GitHub organization or user | Repository         | numbers |
| GitLab.com          | GitLab namespace            | Project            | numbers |
| CircleCI            | CircleCI organization       | Project            | UUIDs   |
| Buildkite           | Buildkite organization      | Pipeline           | UUIDs   |
| Bitbucket Pipelines | Bitbucket workspace         | Repository         | UUIDs   |

* A GitLab namespace is the group or user that directly holds the project. A policy for a group does not cover the projects in its subgroups. A project moved to another namespace stops matching.
* When an owner policy and a project policy both match a job, Currents uses the project policy.
* A job that no policy matches fails with `No trust policy` and prints the IDs to enter. See [No trust policy for the repository](#no-trust-policy-for-the-repository).
* CircleCI Server and Bitbucket Data Center are not supported.

### View or remove a policy

The section lists each policy with its owner or project and its CI provider. **Never used** marks a policy that no job has used yet: its names are the ones an admin typed, and the names from the first job's token replace them.

Select a policy to see its details. To remove it, select **Stop trusting**. Currents then revokes every record key issued through the policy, and jobs that are running lose their key.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fgit-blob-73511fa17c467dc7c0aebcc02157b777e70e10a6%2Foidc-trust-policy-details.png?alt=media" alt="Trust policy details for acme/web: provider GitHub, owner ID, project ID, applies to this project only, token age up to 30 minutes, who added it and when, and the Stop trusting button" width="560"><figcaption></figcaption></figure>

## Configure the CI job

These steps apply to every CI provider:

1. Remove `CURRENTS_RECORD_KEY` and any `--key` or `recordKey` value from the job. A configured record key takes priority, and the reporter does not request a token while one is set. The same holds for an API key on a `currents` command that accepts one.
2. Set the project ID in `CURRENTS_PROJECT_ID` or `--project-id`. With `@currents/playwright`, the `projectId` reporter option also works.
3. Give the job an OIDC token with the audience `currents:record-key`. The sections below show how for each provider.

The examples run `pwc`. With plain `playwright test`, OIDC needs Playwright 1.62 or later, so that the workers get the record key. On an older Playwright, run `pwc`.

In the examples, replace `YOUR_PLAYWRIGHT_VERSION` with the Playwright image tag of your project, and `YOUR_PROJECT_ID` with the Currents project ID.

### GitHub Actions

Add `permissions: id-token: write` to the workflow or the job. The reporter requests the token itself.

```yaml
name: Playwright Tests
on:
  pull_request:
    branches: [main]
permissions:
  id-token: write
  contents: read
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: "24.x"
      - run: npm ci
      - name: Playwright Tests
        env:
          CURRENTS_PROJECT_ID: ${{ vars.CURRENTS_PROJECT_ID }}
        run: npx pwc
```

GitHub normally gives no OIDC token to a pull request from a fork, so that job cannot record. Currents does not check whether a job comes from a fork: it accepts any job whose repository matches a trust policy. Record only from workflows that do not run code from forks.

### GitLab.com

Add an `id_tokens` entry named `CURRENTS_OIDC_TOKEN` to the job, with `aud: currents:record-key`.

```yaml
playwright:
  image: mcr.microsoft.com/playwright:YOUR_PLAYWRIGHT_VERSION
  id_tokens:
    CURRENTS_OIDC_TOKEN:
      aud: currents:record-key
  script:
    - npm ci
    - npx pwc --project-id YOUR_PROJECT_ID
```

### CircleCI

Request a token with the audience `currents:record-key`, and export it as `CURRENTS_OIDC_TOKEN` in the step that runs the tests. The job needs a CircleCI CLI that supports `circleci run oidc get --aud`.

```yaml
version: 2.1
jobs:
  test:
    docker:
      - image: mcr.microsoft.com/playwright:YOUR_PLAYWRIGHT_VERSION
    steps:
      - checkout
      - run: npm ci
      - run:
          name: Playwright Tests
          command: |
            export CURRENTS_OIDC_TOKEN=$(circleci run oidc get --aud currents:record-key)
            npx pwc --project-id YOUR_PROJECT_ID
workflows:
  test:
    jobs:
      - test
```

Do not use `CIRCLE_OIDC_TOKEN_V2` or `CIRCLE_OIDC_TOKEN_V3`. Their audience is the CircleCI organization ID, a job cannot change it, and Currents refuses them.

### Buildkite

Request a token with the audience `currents:record-key`, and export it as `CURRENTS_OIDC_TOKEN`. `buildkite-agent` must be on the `PATH` of the step.

```yaml
steps:
  - label: "Playwright Tests"
    command:
      - npm ci
      - export CURRENTS_OIDC_TOKEN=$(buildkite-agent oidc request-token --audience currents:record-key)
      - npx pwc --project-id YOUR_PROJECT_ID
```

Without `--audience`, the audience is `https://buildkite.com/<organization slug>`, and Currents refuses the token.

### Bitbucket Pipelines

Add `currents:record-key` under `oidc: audiences:` of the step, and copy the step's token to `CURRENTS_OIDC_TOKEN`. To set the audience for every step, add `oidc: audiences:` under `options:` instead.

```yaml
pipelines:
  default:
    - step:
        name: Playwright Tests
        image: mcr.microsoft.com/playwright:YOUR_PLAYWRIGHT_VERSION
        oidc:
          audiences:
            - currents:record-key
        script:
          - npm ci
          - export CURRENTS_OIDC_TOKEN="$BITBUCKET_STEP_OIDC_TOKEN"
          - npx pwc --project-id YOUR_PROJECT_ID
```

Currents accepts the token when `currents:record-key` is one of its audiences.

### Pass the token yourself

On any supported provider, you can get the token yourself and give it to the reporter. The reporter uses the first token it finds:

1. The `oidcToken` reporter option of `@currents/playwright`, or the `--oidc-token` option of the `currents` CLI.
2. The `CURRENTS_OIDC_TOKEN` environment variable.
3. On GitHub Actions, a token the reporter requests itself.

Prefer `CURRENTS_OIDC_TOKEN` to `--oidc-token`: command-line options show in the process list and in logs that echo commands. Keep the token and the record key out of job logs.

### Currents GitHub Actions

#### cancel-run-gh-action

[`cancel-run-gh-action`](https://github.com/currents-dev/cancel-run-gh-action) 1.2.0 or later (`@v1`) cancels a Currents run when the workflow is cancelled. With no `record-key` input, no `api-token` input and no `CURRENTS_RECORD_KEY`, it gets a record key from the job's OIDC token.

The action needs:

* `permissions: id-token: write`
* `project-id` or `CURRENTS_PROJECT_ID`
* the run: `ci-build-id` or `CURRENTS_CI_BUILD_ID`, or `run-id`

```yaml
permissions:
  id-token: write
  contents: read

env:
  CURRENTS_PROJECT_ID: YOUR_PROJECT_ID
  CURRENTS_CI_BUILD_ID: ${{ github.run_id }}-${{ github.run_attempt }}

steps:
  - name: Cancel the Currents run
    if: ${{ cancelled() }}
    uses: currents-dev/cancel-run-gh-action@v1
```

The [action's README](https://github.com/currents-dev/cancel-run-gh-action#inputs) lists every input.

#### playwright-last-failed

[`playwright-last-failed`](https://github.com/currents-dev/playwright-last-failed) 2.2.0 or later (`@v2`) reruns the tests that failed in the last run. Without the `key` input or `CURRENTS_RECORD_KEY`, it gets a record key from the job's OIDC token. It needs `permissions: id-token: write` and the `project-id` input or `CURRENTS_PROJECT_ID`.

The action installs the latest `@currents/cmd` from npm, which has to be 3.1.0 or later. The API mode (`or8n` and `use-api`) still needs `api-key`.

```yaml
permissions:
  id-token: write
  contents: read

steps:
  - name: Playwright Last Failed
    id: last-failed
    uses: currents-dev/playwright-last-failed@v2
    with:
      project-id: YOUR_PROJECT_ID
      matrix-index: ${{ matrix.shard }}
      matrix-total: ${{ strategy.job-total }}
```

## Check that it works

At the start of the run, the reporter prints where the record key came from and when it expires. `pwc` and the Playwright reporter print:

```
Using a record key from GitHub Actions OIDC, valid until 2026-11-14T08:00:00.000Z
```

The `currents` CLI prints:

```
Using a record key from the GitHub Actions OIDC token, valid until 2026-11-14T08:00:00.000Z
```

With a token from `CURRENTS_OIDC_TOKEN` or the token options, the source names that variable or option. Then open the run in the dashboard.

## Troubleshooting

A failed exchange prints a prefix and then the message from Currents. `pwc` and the Playwright reporter print `Could not get a record key from <source>: <message>`. The `currents` CLI prints `Could not exchange the <source> for a record key: <message>`. The examples below show the `pwc` prefix.

### No trust policy for the repository

```
Could not get a record key from GitHub Actions OIDC: No trust policy for GitHub Actions repository "my-org/my-repo" (repository ID 123456789, owner ID 987654321) for the Currents project "YOUR_PROJECT_ID". An admin of the organization that owns the project can add one in the dashboard, under Organization → API and Record Keys.
```

No trust policy matches the job. [Create a trust policy](#create-a-trust-policy) with the IDs the message prints. The policy must be in the organization that owns the project ID the job sends.

### Token is older than the trust policy allows

```
The OIDC token was issued more than 10 minutes ago, which is older than the trust policy allows. Request a new token in the job that calls Currents.
```

The token is older than the **Maximum token age (minutes)** of the policy. Request the token in the step that runs the tests, or raise the limit on the policy.

### Wrong audience

```
The OIDC token audience must be "currents:record-key". Request the token with audience currents:record-key.
```

The token was issued for another audience. Request it with the audience the message names, as shown for your provider in [Configure the CI job](#configure-the-ci-job). A self-hosted Currents has its own audience, see [Self-hosted Currents](#self-hosted-currents).

### Provider not supported

```
The OIDC token issuer "https://gitlab.example.com" is not supported. Supported CI providers: GitHub Actions, GitLab.com, CircleCI, Buildkite, Bitbucket Pipelines.
```

Currents does not accept tokens from this issuer. Currents cloud accepts only the providers in the message. On a self-hosted Currents, the operator can add a self-managed GitLab or GitHub Enterprise Server, see [Self-managed GitLab and GitHub Enterprise Server](#self-managed-gitlab-and-github-enterprise-server). Otherwise, use a record key.

### Organization is inactive

```
The Currents organization that trusts GitHub Actions repository "my-org/my-repo" is inactive.
```

The organization that owns the policy is inactive. Contact support.

### Project ID is not set

`pwc` and the Playwright reporter:

```
Could not get a record key from GitHub Actions OIDC: the project ID is not set. Use the projectId option, CURRENTS_PROJECT_ID or --project-id
```

The `currents` CLI:

```
Project ID is required to get a record key from an OIDC token: pass --project-id or set CURRENTS_PROJECT_ID
```

Set the project ID in the job.

### Record key is required

`pwc` and the Playwright reporter:

```
Record Key is required for Currents Reporter.
```

The `currents` CLI:

```
Record key is required: pass --key or set CURRENTS_RECORD_KEY. Without a stored record key, a CI job can use its OIDC token: set `permissions: id-token: write` on GitHub Actions, or on any other CI put a token in --oidc-token or CURRENTS_OIDC_TOKEN with currents:record-key as its audience (for GitLab `id_tokens`: `aud: currents:record-key`). Staging and on-prem installs use their own audience: set CURRENTS_OIDC_AUDIENCE to its value. https://docs.currents.dev
```

The reporter found neither a record key nor an OIDC token. Both messages go on with a hint on how to give the job a token.

* GitHub Actions: add `permissions: id-token: write` to the workflow or job. A pull request from a fork normally gets no token.
* GitLab.com: add the `id_tokens` entry `CURRENTS_OIDC_TOKEN` to the job.
* CircleCI, Buildkite and Bitbucket Pipelines: export `CURRENTS_OIDC_TOKEN` as shown in [Configure the CI job](#configure-the-ci-job).
* Plain `playwright test` on Playwright older than 1.62: run `pwc` instead.

### OIDC exchange is not available

```
Could not get a record key from GitHub Actions OIDC: Exchanging an OIDC token for a record key is not enabled on this Currents deployment.
```

The Currents server has the exchange turned off. On a self-hosted Currents, the operator turns it on, see [Self-hosted Currents](#self-hosted-currents). Use a record key until then.

```
Could not get a record key from GitHub Actions OIDC: Exchanging an OIDC token for a record key is enabled on this Currents deployment but not configured: it has no OIDC_TOKEN_AUDIENCE.
```

The exchange is on, but `OIDC_TOKEN_AUDIENCE` is not set. Ask the operator to set it.

### Could not revoke the record key

```
Could not revoke the record key from OIDC (<reason>). It expires on its own.
```

`cancel-run-gh-action` logs this warning when it cannot revoke the record key it got. The step does not fail. The record key expires 6 hours after it was issued.

## Self-hosted Currents

A self-hosted Currents has the exchange turned off. The operator turns it on with these settings:

* `OIDC_TOKEN_EXCHANGE_ENABLED=true` turns the exchange on (director).
* `OIDC_TOKEN_AUDIENCE` is the audience that tokens must have (director). It is required when the exchange is on and has no default. Choose a name for the installation, such as `currents:record-key:acme`. Do not use `currents:record-key`: Currents would then accept tokens made for Currents cloud.
* `OIDC_TRUST_FORWARDED_FOR=true` only when a proxy in front of the director appends the client address to `X-Forwarded-For` and drops any value the caller sent (director). Without it, the director counts requests by the address of the connection.
* `OIDC_EXTRA_ISSUERS` lists self-managed GitLab and GitHub Enterprise Server instances (director and API). See [Self-managed GitLab and GitHub Enterprise Server](#self-managed-gitlab-and-github-enterprise-server).

With the Helm chart, the values are `currents.oidcTokenExchange.enabled`, `audience`, `trustForwardedFor` and `extraIssuers`. See the [Docker Compose](https://currents-dev.github.io/docker/configuration.html) and [Kubernetes](https://currents-dev.github.io/helm-charts/docs/) documentation.

The director checks each token against the public signing keys of its issuer, which it fetches over https. For the cloud CI providers, the director needs internet access. For the instances in `OIDC_EXTRA_ISSUERS`, it needs access to those hosts only.

The scheduler creates the MongoDB indexes that the exchange needs when it starts.

In the CI jobs that record to the installation, set `CURRENTS_API_URL` to the director of the installation. Without it, the reporter and the `currents` CLI send the token to Currents cloud, and the exchange fails. `currents` commands that also call the REST API need `CURRENTS_REST_API_URL`, set to the REST API of the same installation.

Then use the audience of the installation instead of `currents:record-key`:

* GitHub Actions: set `CURRENTS_OIDC_AUDIENCE` in the job. The `oidcAudience` reporter option of `@currents/playwright` and the `--oidc-audience` option of the `currents` CLI do the same, and take priority over the variable. For `cancel-run-gh-action`, also set `director-url` to the director of the installation.

  ```yaml
  env:
    CURRENTS_OIDC_AUDIENCE: currents:record-key:acme
  ```
* GitLab, CircleCI, Buildkite and Bitbucket Pipelines: use the audience of the installation where the examples use `currents:record-key`. For example, in GitLab:

  ```yaml
  id_tokens:
    CURRENTS_OIDC_TOKEN:
      aud: currents:record-key:acme
  ```

### Self-managed GitLab and GitHub Enterprise Server

The operator lists the instances in `OIDC_EXTRA_ISSUERS`, as comma-separated `provider=issuer` entries:

```
OIDC_EXTRA_ISSUERS=gitlab=https://gitlab.acme.internal,github=https://ghes.acme.internal/_services/token
```

* The provider is `gitlab` or `github`. A self-managed GitLab uses the URL of the instance as its issuer. GitHub Enterprise Server uses `https://HOSTNAME/_services/token`.
* Currents compares the issuer with the `iss` claim of the token as an exact string. The issuer must be `https`, with a lowercase host, no default port, and no user, password, trailing slash, query or fragment. The director and the API refuse to start with an issuer of a cloud provider, an issuer listed twice, or more than 20 entries.
* The director fetches the signing keys of each listed instance over https and does not follow redirects. For an instance with a certificate from your own certificate authority, set `NODE_EXTRA_CA_CERTS` on the director to the path of a PEM file in the container.
* A trust policy for an instance matches only tokens from that instance, even when its IDs equal IDs on GitLab.com or github.com. To create one, pick the instance in the **Server** menu of **Create trust policy**, and enter the IDs.

**Self-managed GitLab.** Use the same `id_tokens` entry as for GitLab.com, with the audience of the installation:

```yaml
playwright:
  image: mcr.microsoft.com/playwright:YOUR_PLAYWRIGHT_VERSION
  id_tokens:
    CURRENTS_OIDC_TOKEN:
      aud: currents:record-key:acme
  script:
    - npm ci
    - npx pwc --project-id YOUR_PROJECT_ID
```

**GitHub Enterprise Server.** Use the same workflow as for GitHub Actions, with `CURRENTS_API_URL` and `CURRENTS_OIDC_AUDIENCE` set for the installation:

```yaml
permissions:
  id-token: write
  contents: read
jobs:
  test:
    runs-on: [self-hosted]
    env:
      CURRENTS_PROJECT_ID: ${{ vars.CURRENTS_PROJECT_ID }}
      CURRENTS_API_URL: https://currents.acme.internal
      CURRENTS_OIDC_AUDIENCE: currents:record-key:acme
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npx pwc
```

The runner must trust the certificates of the Currents installation and of the instance when they come from an internal certificate authority.

## Next step

{% content-ref url="/pages/sH02jqxKMiXN9BCHUaQn" %}
[Record Key](https://docs.currents.dev/guides/record-key)
{% endcontent-ref %}


# Reporting


# Reporting Strategy

How to structure and organize the reporting of CI test results to Currents

This guide aims to help readers understand how to structure and organize the test result reporting in Currents. It covers key concepts such as project, runs and groups hierarchy, test result handling, and integration strategies.

By following this guide, users can optimize their test reporting workflow and gain clearer insights into their test runs.

## Currents Reporting Terms

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fnpal8Bz1fatdattxXuFr%2FTopology.png?alt=media&amp;token=9248d920-adcd-44e6-8ccb-191255e463d8" alt=""><figcaption><p>Reporting entities and their relationship</p></figcaption></figure>

### **Project**

The top-level entity representing reporting destination. Each organization can have multiple projects, there’s no limit on the number of projects.

You specify the project when running tests in your CI pipeline using environment variables `CURRENTS_PROJECT_ID` or via reporter configuration. Please refer to reporter documentation for available options.

{% hint style="info" %}
Each project maintains separate settings and data, with no crossover
{% endhint %}

#### **Test Results and History**

* Test results from different projects remain separate, even for identical tests.
* Test history displays results only from the same project.
* Performance metrics only include test recordings from the same project.

#### **Integrations**

Each project has its own integrations with 3rd parties (see [Integrations](https://docs.currents.dev/resources/integrations)). However, multiple projects can be connected to the same destination.

For example, enabling a GitHub integration allows selecting the same GitHub organization and repository for different projects. However, this may result in duplicate PR comments originating from separate projects connected to the same repository.

***

### **Run**

A recording of test results from a CI run, uniquely identified by a [CI Build ID](https://docs.currents.dev/guides/parallelization-guide/ci-build-id), git commit information and CI provider execution details.

By default each run represents a build (or execution of a CI pipeline), however, you can send results from different stages of a pipeline or even different pipelines to the same run using the same CI Build ID value. See [CI Build ID](https://docs.currents.dev/guides/parallelization-guide/ci-build-id).

***

### **Group**

A collection of spec files and the corresponding test results. For example:

* in Playwright you can create two Playwright projects that run the same tests for `chrome` and `firefox` - Currents will create a separate group, accordingly.
* in Postman each “collection” corresponds a separate group.

Each group can contain multiple spec files and test results.

***

### **Spec File**

A file containing one or more test cases, identified by its reporter filesystem path. Currents collects certain performance metrics for specs. Spec file can contain zero or more test recordings.

***

### **Test Recording**

A single test execution result, including attempts, attachments (screenshots, videos, traces, arbitrary attachments, visual diff results, annotations, error details. Each test record can have multiple attempts.

***

### **Attempt**

An attempt to run of a test case. Multiple attempts may occur depending on retry strategies.

## Reporting Scenarios

You can implement various reporting scenarios using a combination of Projects, Runs and Groups. Consider the following popular scenarios.

### Single product / repository

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FonLjN0LaIXl4DPvdWrni%2Fsingle%20project.png?alt=media&amp;token=b8b28dda-66c4-4b72-9d7a-5a722ca3a9b2" alt=""><figcaption><p>Reporting scenario: single repository with (optionally) multiple groups</p></figcaption></figure>

You have a single product (and a repository) and a testing suite that runs as part of a CI pipeline, all tests run together, optionally multiple groups (e.g. `chromium` and `firefox` ) will be automatically detected.

It is recommended to have a single project and create a unique run on every invocation of the CI pipeline.

* Create a single project
* Create a unique run for each CI invocation
* Create single or multiple groups within each run

### Multiple standalone products / repositories

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FhowHMsILc8HzyaGwYmsG%2Fstandalone-multiple-products.png?alt=media&amp;token=b5397b5a-d16d-44d1-80cf-4cfed7d9d1b7" alt=""><figcaption><p>Reporting scenario: multiple standalone repositories report to different Currents Projects</p></figcaption></figure>

For bigger organizations, each product has its own repository and testing suite that runs as part of a CI pipeline.

* Create a dedicated project for each product / repository
* Create a single run for each CI invocation
* Create a single or multiple groups for each run

### Mixed reporting, multiple environments

A more complicated scenario is when you have a testing suite that runs in different "environments" and you need to decide how to organize the test results. For example:

* running different Playwright projects in separate CI steps
* running the same set of tests in multiple environments, e.g. based on locale (`en-us`, `en-ca` ) or a domain (`com`, `.co.uk`)
* running a subset of tests based on tags or glob pattern, e.g. `playwright test --grep @desktop`
* running a subset of tests from different CI steps (or different pipelines) while separating the results

To implement the variety of possible scenarios you need to use the combination of Project, CI build ID, Groups and Tags, become familiar with the limitations and implications.

### Example

For example, consider testing an e-commerce web app with a slightly different set of Playwright tests for different domains (`.com`, `.co.uk` etc.).

You've defined the following [Playwright projects](#user-content-fn-1)[^1]

{% code title="playwright.config.ts" %}

```typescript
export default {
  // ...
  projects: [
    {
      name:"UK",
      testMatch: ["./e2e/shared/*.spec.ts", "./e2e/uk/*.spec"],
      use: {
        baseURL: "example.co.uk" // 🇬🇧
      }
    },
    {
      name: "US",
      testMatch: ["./e2e/shared/*.spec.ts", "./e2e/us/*.spec"],
      use: {
        baseURL: "example.com" // 🇺🇸
      }
    },
  ]
}
```

{% endcode %}

Let's consider various setups and the implications.

#### Single project, single run, multiple groups

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FfMyBvgcryrocRbasQ4i1%2Fmixed-add-group.png?alt=media&amp;token=7accce6e-21fa-44f8-b007-39e38536bbf5" alt=""><figcaption><p>Mixed reporting: CI steps create separate groups in a run</p></figcaption></figure>

<details>

<summary>Example: single project, single run, multiple groups</summary>

This is the default reporting model that uses the same `projectId` (hence sends results to the same project) and the same `ci-build-id` (hence sends the results to the same run) for each command. Assuming Currents reporter is already configured.

* Running `playwright test --project UK` will create a new run with a group `UK`
* Running `playwright test --project US` will update the previosuly created run by adding the new group `US`

<table><thead><tr><th width="297">Item</th><th>Description</th></tr></thead><tbody><tr><td>Project Settings: Timeout</td><td>Each run has its own timeout, both groups will have to finish within the designated time to prevent a timeout</td></tr><tr><td>Project Settings: Default branch</td><td>Same for all runs and groups</td></tr><tr><td>Project Settings: Run title source</td><td>Same for all runs and groups (same project)</td></tr><tr><td>Project Settings: Fail fast</td><td>Each run has its own fail-fast settings</td></tr><tr><td><a data-mention href="https://docs.currents.dev/resources/integrations">Integrations</a></td><td>Integration settings are set on a project level. Each run will activate its own notifications. Depending on integration settings you may receive a separate notification for each group completion or only for the whole run.</td></tr><tr><td><a data-mention href="https://docs.currents.dev/guides/currents-actions">Currents Actions</a></td><td>Actions are defined on Project level and apply to each run and both groups.</td></tr><tr><td>Run Results</td><td>Each run contains results for run both group and all the included tests.</td></tr><tr><td>Run Metrics</td><td>Run metrics are based on mixed results from the two groups: aggregated run duration includes both groups, suite size includes test from both groups.</td></tr><tr><td>Test Metrics</td><td>Test metrics are based on both groups, for example if test A runs in group UK and US then both samples of the test will be included in its metrics (duration, flakiness rate, failure rate). It is possible to include only samples from particular group by using group filter.</td></tr><tr><td>Coverage Reports</td><td>Coverage reports are collected on a group level</td></tr><tr><td>Scheduled Reports</td><td>Scheduled automated reports are defined on project level and will contain results for both groups</td></tr><tr><td>Error Aggregations</td><td>Error aggregations include results from both groups</td></tr><tr><td>Test Explorer and History</td><td>Test results, including history contain results from both groups. It is possible to filter the results only from particular group</td></tr><tr><td><p>Project Taxonomy</p><p>(tags, git info, groups) - filters</p></td><td>Project taxonomy includes items from all runs and groups</td></tr></tbody></table>

</details>

#### Single project, multiple runs, single group

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FxWwyHRQmGBRYZqSm4MuN%2Fmixed-new-run.png?alt=media&amp;token=394116d6-de7d-4552-b8ea-86cc4fdb0b37" alt=""><figcaption><p>Mixed reporting: Each CI step create a new run</p></figcaption></figure>

<details>

<summary>Example: Single project, multiple runs, single group</summary>

Instead of sending the results to the same run, you can chose to create a separate run for each playwright group. Run the following commands as part of your CI pipeline (assuming Currents reporter is already configured).

* Use the same `projectId` (send results to the same project)
* Use a different `ci-build-id` for each group - setting a different value would create a new run:
  * <mark style="color:yellow;">`CURRENTS_BUILD_ID=build-001-uk`</mark>` `` ``playwright test --project UK ` (creates a new run with a single group UK)
  * <mark style="color:yellow;">`CURRENTS_BUILD_ID=build-001-us`</mark>` `` ``playwright test --project US ` (creates a new run with a single group US)

In this case, instead of a single run that contains two groups, you will create two separate runs with with 1 group each.

<table><thead><tr><th width="280">Item</th><th>Description</th></tr></thead><tbody><tr><td>Project Settings: Timeout</td><td>Each run has its own timeout</td></tr><tr><td>Project Settings: Default branch</td><td>Same for all runs</td></tr><tr><td>Project Settings: Run title source</td><td>Same for all runs</td></tr><tr><td>Project Settings: Fail fast</td><td>Each run has its own fail-fast settings</td></tr><tr><td><a data-mention href="https://docs.currents.dev/resources/integrations">Integrations</a></td><td>Integration settings are set on a project level. Each run will activate its own notifications</td></tr><tr><td><a data-mention href="https://docs.currents.dev/guides/currents-actions">Currents Actions</a></td><td>Actions are defined on Project level and apply to each run</td></tr><tr><td>Run Results</td><td>Each run contains results of a single group</td></tr><tr><td>Run Metrics</td><td>Aggregated run metrics are based on mixed results from the two types of runs. For example, suite size includes test from both groups. It is possible to refine the aggregation metrics to only include runs with particular tags. See <a data-mention href="https://docs.currents.dev/guides/playwright-tags">Playwright Tags</a></td></tr><tr><td>Test Metrics</td><td>Test metrics are based on all runs, for example if test A runs in both environments, then both samples of the test will be included in its metrics (duration, flakiness rate, failure rate). It is possible to include only samples from particular run or group by using tags. See <a data-mention href="https://docs.currents.dev/guides/playwright-tags">Playwright Tags</a>.</td></tr><tr><td>Coverage Reports</td><td>Coverage reports are collected on a group level.</td></tr><tr><td>Scheduled Reports</td><td>Scheduled automated reports are defined on project level and will contain results for both types of runs. It possible to refine the reports using <a data-mention href="https://docs.currents.dev/guides/playwright-tags">Playwright Tags</a>.</td></tr><tr><td>Error Aggregations</td><td>Error aggregations include results from both types of runs.</td></tr><tr><td>Test Explorer and History</td><td>Test results, including history contain results from all runs.. It is possible to filter the results only from particular run using <a data-mention href="https://docs.currents.dev/guides/playwright-tags">Playwright Tags</a>..</td></tr><tr><td><p>Project Taxonomy</p><p>(tags, git info, groups) - filters</p></td><td>Project taxonomy includes items from all runs</td></tr></tbody></table>

</details>

<details>

<summary>Multiple projects, single run, single group</summary>

As an edge case it is possible to use completely different projects. Keep in mind that each project's data is completely separated. Each project has its own set of settings, analytics, results and integrations.

Use different `projectId` for each command (assuming projects already exist)

* <mark style="color:yellow;">`CURRENTS_PROJECT_ID=1cVv3a`</mark>` `` ``playwright test --project UK ` (creates a new run with a single group UK)
* <mark style="color:yellow;">`CURRENTS_PROJECT_ID=aXcR4sa`</mark>` `` ``playwright test --project US ` (creates a new run with a single group US)

</details>

## Using Tags

Regardless of the reporting strategy we recommend to annotate your tests and executions with tags. Adding tags allows granular access to the data.

* Read more about using [Playwright Tags](https://docs.currents.dev/guides/playwright-tags) to dynamically add tags to runs, groups and tests
* Consider using `removeTitleTag`in [@currents/playwright](https://docs.currents.dev/resources/reporters/currents-playwright) to remove tags from test title and keep test history consistent

[^1]: don't confuse with Currents Projects


# CI Build ID

Using CI Build ID for reporting to Currents

## What is CI Build ID?

**CI Build ID** is a unique identifier used by Currents to collect test results. Think of it as a hard drive "folder". We call it a Run (see [Runs](https://docs.currents.dev/dashboard/runs)).

For example, when multiple CI machines run tests in parallel, their combined results are combined if they use the same CI Build ID.

* results with `--ci-build-id build001` will go to `build001` "folder"
* results with `--ci-build-id build002` will go to `build002` "folder"

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FrfjpnqDJX7016jSLUMHC%2Fci-build-id.png?alt=media&amp;token=bd3bb8c5-ead1-4ee4-81f2-3b880b04af0c" alt=""><figcaption><p>Creating two distinct runs by using different CI Build ID</p></figcaption></figure>

## Creating a CI Build ID

You can choose between leveraging our auto-detection algorithm, or manually generating a CI Build ID.

### Automatic Detection

Currents automatically detects CI Build ID for popular CI providers based on the presence of environment variables. Please refer to [#build-id-for-popular-ci-providers](#build-id-for-popular-ci-providers "mention") to see the environment variables used for each provider.

Otherwise, if not explicitly provided, Currents generates a random unique id.

### Explicit Value

You can also specify CI Build ID explicitly.

{% tabs %}
{% tab title="CLI" %}
With the CLI, you can use the `--ci-build-id` flag, for example:

```bash
pwc run --ci-build-id CI_BUILD_ID --key xxx --project-id yyy
```

{% endtab %}

{% tab title="Reporter Configuration" %}
Example on passing ciBuildId to Playwright Reporter configuration:

```javascript
// playwright.config.ts
import { currentsReporter } from '@currents/playwright';

//...
reporter: [
  currentsReporter({
    //... 
    ciBuildId: process.env.CURRENTS_CI_BUILD_ID
  }),
]
```

{% endtab %}

{% tab title="Environment Variable" %}
You can also set the `CURRENTS_CI_BUILD_ID` environment variable to provide an explicit CI Build ID value.
{% endtab %}
{% endtabs %}

In order to manually construct a CI Build ID that is unique for each build (but similar across all the parallel machines) it is recommended to use your CI provider's environment variables that combine pipeline/workflow/build identifier and also an attempt number.

For example, for GitHub Actions:

```
--ci-build-id "${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}"
```

Refer to your CI provider documentation for the list of available environment variables.

## Examples

### Different CI Build ID, Different Builds

Imagine a CI pipeline running tests in parallel using multiple machines. Starting two builds with a **different CI Build ID** will create 2 distinct "Runs" in Currents dashboard.

The reporting will happen for each build independently from the other. That is usually the desired situation - each build should have a unique CI Build ID.

### Same CI Build ID, Different builds

In contrast, consider a situation when 2 **different** builds use the **same** CI Build ID. That's an uncommon situation, but it's worth demonstrating for understanding the use of CI Build ID.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FM4mzD3KHDcXK1CfHGssk%2Fci-build-id-same.png?alt=media&amp;token=0352b95e-a3fe-4b67-89fe-9bbd6dfe99c6" alt=""><figcaption><p>A single run is created when using a similar CI Build ID</p></figcaption></figure>

We created two different builds with the same CI Build ID. That will result in 6 machines reporting their results to the same run.

### Build ID for Popular CI Providers

Currents tries to automatically detect the CI provider by looking at the environment variables and picking the best combination.

<details>

<summary>Build ID for Popular CI Providers Table</summary>

<table><thead><tr><th width="193">Provider</th><th width="317">Variables</th><th>Fallback</th></tr></thead><tbody><tr><td>AppVeyor</td><td><ul><li>APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH</li><li>APPVEYOR_BUILD_NUMBER</li></ul></td><td><ul><li>APPVEYOR_BUILD_NUMBER</li></ul></td></tr><tr><td>Azure</td><td><ul><li>BUILD_BUILDID</li></ul></td><td></td></tr><tr><td>AWS Code Build</td><td><ul><li>CODEBUILD_BUILD_ID</li><li>CODEBUILD_SOURCE_VERSION</li></ul></td><td><ul><li>CODEBUILD_BUILD_ID</li></ul></td></tr><tr><td>Bamboo</td><td><ul><li>bamboo_buildKey</li><li>bamboo_buildNumber</li></ul></td><td><ul><li>bamboo_buildKey</li></ul></td></tr><tr><td>Bitbucket</td><td><ul><li>BITBUCKET_REPO_SLUG</li><li>BITBUCKET_BUILD_NUMBER</li></ul></td><td><ul><li>BITBUCKET_BUILD_NUMBER</li></ul></td></tr><tr><td>Buildkite</td><td><ul><li>BUILDKITE_BUILD_ID</li></ul></td><td></td></tr><tr><td>CircleCI</td><td><ul><li>CIRCLE_WORKFLOW_ID</li></ul></td><td><ul><li>CIRCLE_BUILD_NUM</li></ul></td></tr><tr><td>Codeship</td><td><ul><li>CI_REPO_NAME</li><li>CI_BUILD_ID</li></ul></td><td><ul><li>CI_BUILD_ID</li></ul></td></tr><tr><td>Concourse</td><td><ul><li>BUILD_ID</li><li>BUILD_NAME</li></ul></td><td><ul><li>BUILD_ID</li></ul></td></tr><tr><td>CodeFresh</td><td><ul><li>CF_BUILD_ID</li><li>CF_CURRENT_ATTEMPT</li></ul></td><td><ul><li>CF_BUILD_ID</li></ul></td></tr><tr><td>Drone</td><td><ul><li>DRONE_PULL_REQUEST</li><li>DRONE_BUILD_NUMBER</li></ul></td><td><ul><li>DRONE_BUILD_NUMBER</li></ul></td></tr><tr><td>GitHub Actions</td><td><ul><li>GITHUB_REPOSITORY</li><li>GITHUB_RUN_ID</li><li>GITHUB_RUN_ATTEMPT</li></ul></td><td><ul><li>GITHUB_RUN_ID</li></ul></td></tr><tr><td>GitLab</td><td><ul><li>CI_PIPELINE_ID</li></ul></td><td></td></tr><tr><td>GoCD</td><td><ul><li>GO_REVISION</li><li>GO_PIPELINE_COUNTER</li></ul></td><td><ul><li>GO_REVISION</li></ul></td></tr><tr><td>Google Cloud</td><td><ul><li>REPO_NAME</li><li>BUILD_ID</li></ul></td><td><ul><li>BUILD_ID</li></ul></td></tr><tr><td>Jenkins</td><td><ul><li>BUILD_NUMBER</li></ul></td><td></td></tr><tr><td>Semaphore</td><td><ul><li>SEMAPHORE_GIT_REPO_SLUG</li><li>SEMAPHORE_PIPELINE_ID</li></ul></td><td><ul><li>SEMAPHORE_PIPELINE_ID</li></ul></td></tr><tr><td>TeamFoundation</td><td><ul><li>BUILD_BUILDID</li><li>BUILD_BUILDNUMBER</li></ul></td><td><ul><li>BUILD_BUILDID</li></ul></td></tr><tr><td>Travis</td><td><ul><li>TRAVIS_REPO_SLUG</li><li>TRAVIS_BUILD_ID</li></ul></td><td><ul><li>TRAVIS_BUILD_ID</li></ul></td></tr><tr><td>Netlify</td><td><ul><li>BUILD_ID</li></ul></td><td></td></tr></tbody></table>

</details>

## Next Steps

Now, after you're familiar with CI Build ID, explore [Reporting Strategy](https://docs.currents.dev/guides/parallelization-guide/reporting-strategy) to customizing your reporting to Currents.

## FAQ

<details>

<summary>Retrying builds and CI Build ID</summary>

Imagine a situation

* You start a new build with CI Build ID **build-001**
  * Build completes and reports all the results to Currents Dashboard
  * Currents marks build-001 as "finished" and all the files as completed
* You restart the build (attempt B), but keep the same CI build ID **build-001**
  * Currents considers **build-001** as already completed
  * Currents won't accept new results for **build-001**, because all the results were already reported
  * Currents will not send any new files for Cypress orchestration, because build-001 already ran all the spec files on the first attempt

To resolve this ambiguity, we need to have a different CI build ID for each rerun.

Most CI providers provide a different set of environment variables for different attempts and Currents dashboard can identify it automatically - it will create an entirely new run for retries.

You can also construct an explicit CI Build ID when retrying a build, for example, for GitHub Actions:

```
"${{ github.repository }}-${{ github.run_id }}-${{ github.run_attempt }}"
```

If you are generating CI Build ID manually, please make sure to include the retry/attempt identifier.

Please refer to your CI tool documentation to explore what environment variables are available for composing a valid CI Build ID.

</details>

<details>

<summary>Using commit SHA as CI Build ID</summary>

Using commit SHA as a CI Build ID is a valid approach and can work for many setups. However, please be aware that rerunning a build with the same commit SHA can result in a duplicate CI Build ID and prevent orchestration and reporting (see [#examples](#examples "mention"))

</details>

<details>

<summary>How to rerun CI with only failed tests?</summary>

See [Re-run Only Failed Tests](https://docs.currents.dev/guides/ci-optimization/re-run-only-failed-tests)

</details>


# Reporting in CI

Playwright Sharding and reporting the results to Currents

By default, Playwright runs the test files in parallel using several worker processes that run on the same machine (see [Playwright docs](https://playwright.dev/docs/test-parallel)). In addition to machine-level parallelization with workers, you can split the spec files between multiple machines using **sharding**.

### What is Playwright Sharding?

As mentioned, Playwright runs test files in parallel by default, but you can scale this behaviour by running tests on multiple machines simultaneously. This is called [sharding in Playwright](https://playwright.dev/docs/test-sharding) parlance.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FyoSk8DKcZeG0Nc2kixy6%2Fplaywright-sharding-example.png?alt=media&amp;token=9a5c7c50-6018-46ad-8770-74cf4c34e9b1" alt=""><figcaption><p>Running Playwright tests with sharding</p></figcaption></figure>

This behaviour is activated by using the `--shard` flag. For example:

```
npx playwright test --shard 1/2
```

Currents collects test results across different machines + workers and presents them in the cloud dashboard, using CI Build ID to assign the results to a build/run.

### Reporting Sharded Playwright from localhost

Running Playwright tests with sharding enabled on localhost requires running two or more `playwright` commands with the `--shard` flag and the same [CI Build ID](https://docs.currents.dev/guides/parallelization-guide/ci-build-id).

Open two separate terminals and run an identical `pwc` command with `--shard=1/2` and `--shard=2/2` flag respectively and `--ci-build-id` flag with identical values in both terminals. In the example below we use a dummy CI build ID `ciid`, you can replace it with any value as long as it's the same.

{% code overflow="wrap" %}

```
npx pwc --key <currents key> --project-id <currents project id> --ci-build-id ciid --shard=1/2
```

{% endcode %}

{% code overflow="wrap" %}

```
npx pwc --key <currents key> --project-id <currents project id> --ci-build-id ciid --shard=2/2
```

{% endcode %}

You will see that two shards are executing different spec files and running in parallel, and the number of workers executing tests on each one of the shards.

### Splitting Test Files for Sharding

You don't need to split files manually when using Currents - Playwright does that for you automatically and distributes the spec files between Playwright shards and workers.

By default, Playwright runs test files in alphabetical order and distributes the files between shards and workers on each shard. You can use some naming convention to control the test order, for example:

* `001-user-signin-flow.spec.ts`
* `002-create-new-document.spec.ts`

In addition, you can enable [Fully Parallel Mode](https://docs.currents.dev/guides/ci-optimization/fully-parallel-mode) in a single file, so Playwright will split individual tests instead of test files.

### What CI Providers Support Playwright Sharding?

Any CI provider or tool that allows creating multiple containers/jobs can be integrated with Currents for running Playwright sharding.

Here are a few example setups for popular CI providers:

* [GitHub Actions](https://github.com/currents-dev/currents-examples/tree/main/playwright/ci/github-actions)
* [GitLab](https://gitlab.com/currents.dev/gitlab-playwright-currents)
* [CircleCI](https://github.com/currents-dev/currents-examples/tree/main/playwright/ci/circleci)
* [Jenkins](https://docs.currents.dev/getting-started/ci-setup/jenkins)


# Step-Level Reporting

Live test results: near-realtime streaming of step-level progress from CI machines

Traditionally, Playwright reporters generate results **after** the run completion, when all the results are ready. This approach works well when executions are successful. However, when an execution fails to complete, no results are reported at all.

For example, imagine running a spec file with 10 tests on a CI machine. Nine tests can be completed successfully, but the last test can cause a crash. If we report after completion, no results will be reported at all, even for the nine finished tests.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FnlKaqnmUmN0tekBfTgf4%2FTraditional%20reporting%20fails%20when%20execution%20doesn%E2%80%99t%20finish.png?alt=media&amp;token=be046c7b-c1ee-45f0-95f6-89de1ace01f0" alt="Failure to finish test execution can result in no results reported at all"><figcaption><p>Failure to finish test execution can result in no results reported at all</p></figcaption></figure>

This problem affects not only the test results per se but also the generating and uploading of artifacts like traces, screenshots, and videos. We observed this issue occurring in different scenarios, ranging from infrastructure issues to Playwright bugs.

We wanted to provide a crash-resilient solution that would help debug failed CI tests and provide as much information as possible as soon as it is available. The Currents reporter **streams the results for each individual step**, including step-level lifecycle events (e.g., step started, step ended), as soon as they're available. So, even if an execution crashes, Currents will capture the last step that caused the failure.

In addition, Currents uploads the generated artifacts to cloud storage as soon as they are available, so you can access them even if the execution crashes.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2F1wUJSU3sxpNOk1h9U47B%2Fpw-currents-streaming.png?alt=media&amp;token=94be9e8e-c6ef-4ff2-a8c3-4661a24b6302" alt=""><figcaption><p>Streaming step-level results in Currents reporter for Playwright tests</p></figcaption></figure>

In addition to being resilient to crashes, collecting data about individual steps allows Currents to present detailed information via its web interface. The results are stored in cloud storage, providing easy access to the entire team during Playwright tests execution. Think of it as a light version of Playwright traces that are available immediately and are not dependent on the test completion or the successful upload of a trace file.

Such detailed information unlocks more insights, like step-level analytics and performance analysis.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FRxxh0LTJ4ckdIIJMkidc%2FScreenshot%202026-01-15%20at%2017.27.48.png?alt=media&amp;token=425bc324-6b2b-40c4-8111-325a0c9c81da" alt=""><figcaption><p>Streaming step-level results in Currents reporter for Playwright tests</p></figcaption></figure>

It's important to note that step-level reporting is available because the Playwright team and other contributors have designed and provided the necessary APIs to capture the lifecycle events of the test execution.


# Test Orchestration

The better alternative to Playwright Sharding

Scaling a test suite comes with many challenges. As the test suite grows, CI becomes slower.

Playwright [parallelism](https://playwright.dev/docs/test-parallel) helps reducing the bottleneck, but they aren't as efficient as they could be. Sharding splits test files based on the lexical order of file paths, leading to unbalanced workloads.

Currents Test Orchestrator fixes that by balancing the load using historical execution data, continuously creating the most optimal execution order for test runs, resulting in [up to 40% reduction the CI execution time](https://currents.dev/posts/currents-and-fundguard) with minimal changes to configuration.

<figure><img src="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FSFVeS0aNygUEgZ9lNRre%2FOrchestration.png?alt=media&amp;token=ecbc5eb7-046c-4f45-85f1-189601ec84a4" alt=""><figcaption></figcaption></figure>

Instead of pre-allocating tests to CI nodes, the orchestrator keeps a live queue of pending tests and dynamically assigns them to machines as they become available. This allows continuous communication and coordination across all nodes, improving overall throughput.

* **Learning from history** - tracks test durations and uses that data to improve distribution in future runs.
* **No renaming hacks** - you don’t need to rename spec files or manually tune splits for better balance.
* **Dynamic test distribution** - tests are split based on real-time machine availability, not pre-assigned upfront.
* **Handles CI quirks** - automatically adapts to runner spin-up delays or unresponsive machines.
* **Scales with your suite** - maintains high throughput as test count, duration, or structure evolves.
* **Your CI, your environment** - the tests are running on your existing environment, the orchestrator client communicates with Currents for task assignments and reporting the results.
* **It's just Playwright** - an orchestrator uses Playwright internally, using the same configuration and interfaces to run the tests.

### Get Started

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-card-cover data-type="image">Cover image</th></tr></thead><tbody><tr><td><strong>Technical Deep Dive</strong></td><td><sup>Fully understand how Test Orchestration works and how it compares to native Playwright Sharding.</sup></td><td><a href="https://docs.currents.dev/guides/ci-optimization/playwright-parallelization">Playwright Parallelization</a></td><td><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2FuUKHS2vjzjRYuhgUWwxC%2Fcurrents-orchestration-queue.png?alt=media&amp;token=bfeaf3f1-397a-4d45-9686-9f9750b07d32">currents-orchestration-queue.png</a></td></tr><tr><td><strong>Setup Orchestration</strong></td><td><sup>Read the guide on how to setup Test Orchestration in your test suite.</sup></td><td><a href="https://docs.currents.dev/guides/ci-optimization/playwright-orchestration">Orchestration Setup</a></td><td data-object-fit="contain"><a href="https://3745692499-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqmFDEiUa9mr11LUlxDnt%2Fuploads%2Fl3AUQ3L6DcZCLneBBH3C%2Fplaywright-logo-neo.png?alt=media&amp;token=a89ab480-a068-4969-91fc-d45ae1dcb8b9">playwright-logo-neo.png</a></td></tr></tbody></table>




---

[Next Page](https://docs.currents.dev/llms-full.txt/1)

