Your First Playwright Run

Running Playwright tests with Currents Dashboard

Integrating Currents with Playwright enables recording test results together with screenshots, videos, and traces to the cloud reporting service. That unlocks more effective troubleshooting, analytics and proactive monitoring, extending your team's workflows using REST API, WebHooks and built-in integration with Slack, GitHub etc.

Overview

Here's an overview of what steps you'll need to take to start running Playwright tests using the Currents dashboard and a CI:

  • Create an organization and a project

  • Install @currents/playwright npm package

  • Enable traces, videos and screenshots in playwright.config.js|ts to enhance the dashboard test results

  • Run the tests using pwc CLI command or by configuring an extra reporter

  • Update your CI provider configuration

Setting Up Playwright in 2 minutes

Create an 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 their names later.

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

Select Playwright from the framework selection list and then choose the preferred installation method (see below).

Install @currents/playwright package

npm i -D @currents/playwright

Update playwright.config.js|ts

Disable fullParallel mode and parallelizing tests in a single file - it is not currently supported by Currents

Enabled traces, videos and screenshots in playwright.config.js|ts to enhance the dashboard test results.

use: {
    // ...
    trace: "on",
    video: "on",
    screenshot: "on",
  }

Create your first Playwright run

@currents/playwright provides an executable script named pwc - it runs playwright with a predefined configuration.

Alternatively, you can add @currents/playwright reporter to playwright.config.ts

Using pwc CLI command

Run pwc to create your first Playwright run in Currents dashboard.

npx pwc --key RECORD_KEY --project-id PROJECT_ID --ci-build-id hello-currents
  • Set the Record Key, and Project ID obtained from Currents dashboard in the previous step.

  • Provide --ci-build-id to identify this run in the dashboard - the example above uses hello-currents as the build ID.

Please note that CI environments require generating the Build ID based on CI environment variables.

@currents/playwright automatically detects the Build ID for popular CI providers, but in some cases, you need to define it explicitly.

We encourage you to invest 3 minutes into learning more about CI Build ID to prevent confusion during the setup.

Manually configuring @currents/playwright reporter

Alternatively, you can explicitly add the reporter to Playwright configuration:

import { defineConfig, devices, PlaywrightTestConfig } from "@playwright/test";
import { CurrentsConfig, currentsReporter } from "@currents/playwright";

const currentsConfig: CurrentsConfig = {
  ciBuildId: "ci-build-id", // 📖 https://currents.dev/readme/guides/ci-build-id
  recordKey: "secret record key", // 📖 https://currents.dev/readme/guides/record-key
  projectId: "project id", // get one at https://app.currents.dev
};

const config: PlaywrightTestConfig = {
  use: {
    trace: "on",
    video: "on",
    screenshot: "on",
  },
  
  reporter: [currentsReporter(currentsConfig)], // 👈🏻 add Currents reporter

  projects: [
    {
      name: "chromium",
      retries: 2,
      use: {
        ...devices["Desktop Chrome"],
      },
    },
  ],

};

export default defineConfig(config);

You can also set environment variables to provide the configuration options to Currents reporter:

CURRENTS_PROJECT_ID=PROJECT_ID \ // the projectId from https://app.currents.dev
CURRENTS_RECORD_KEY=RECORD_KEY \ // the record key from https://app.currents.dev
CURRENTS_CI_BUILD_ID=hello-currents \
npx playwright test

With the reporter configured, you can run npx playwright test to start sending the results to Currents dashboard.

Explore the Newly Created Run

If Currents reporter is set up correctly, the execution results will show on the Currents dashboard. Additionally, a link to the recorded run will also be available at the end of the execution:

Now you can start configuring your CI environment to record Playwright tests to Currents. Please consider exploring those guides to ensure smooth configuration:

Update CI Provider Configuration

Treat the Record Key as a Ci secret - don't expose it publicly

In order to collect results from multiple CI runners, please make sure that --ci-build-id is similar across parallel machines, but is unique for each build.

Please reach out to our in-app support chat to get help with setting up the CI pipeline.

Currents support collecting results from parallel executions on multiple machines using the built-in Playwright Sharding. The results will be kept as a single dashboard run as long as they share the same CI build ID.

Check out the example for popular CI providers below, more examples for different providers will be added in future.

Examples

Check out the example repositories that showcase running Playwright tests on popular CI providers and recording the results to Currents:

Explore @currents/playwright npm package documentation for configuration options.

Last updated