@currents/playwright
Playwright integration and reporting tool for Currents - a cloud dashboard for debugging, troubleshooting and analysing parallel CI tests supporting Cypress and Playwright.
Documentation | Currents
- Saves traces, videos, screenshots and console output to a cloud
- Fetches git information and associated with CI builds
- Integrates with your workflow - Slack, GitHub or GitLabPR comments and status checks
- Flakiness, failure rate, duration and much more aggregative metrics
- Powerful history and trends browser on test or spec level
- Common errors tracker
- Automated reports with test suite health metrics
- REST API and HTTP Webhooks
Install
Make sure you already have Playwright installed, then run:
npm install @currents/playwright
Enable traces, screenshots and videos
use: {
trace: "on",
video: "on",
screenshot: "on",
}
Usage
Choose the preferred launch method:
- executing a
pwc
CLI command - it runs playwright with a predefined configuration - add
@currents/playwright
reporter to Playwright configuration file
pwc
CLI
We need to pass three parameters to run pwc
:
- our record key
- the project ID, which is created when you create a project in the Current dashboard
- the CI build ID
The command passes down all the other CLI flags to the Playwright test runner as-is. We can pass these as command line arguments, as environment variables, or a mixture of both.
pwc --project-id PROJECT_ID --key RECORD_KEY --ci-build-id hello-currents
@currents/playwright
reporter
Alternatively, you can manually add the reporter to playwright configuration and keep using playwright test
CLI command.
import type { PlaywrightTestConfig } from "@playwright/test";
const config: PlaywrightTestConfig = {
reporter: [
["@currents/playwright"],
],
};
export default config;
If you choose to add the reported manually, preset environment variables before running playwright command
CURRENTS_RECORD_KEY=RECORD_KEY CURRENTS_PROJECT_ID=PROJECT_ID CURRENTS_CI_BUILD_ID=hello-currents npx playwright test
Examples
Check out the example repository for integrating with GitHub Actions: https://github.com/currents-dev/playwright-gh-actions-demo, including parallel runs on multiple machines using Playwright shards.
Here’s a quick reference to configuration files:
Screenshots
By default Playwright only captures screenshots at the end of a test, according to the provided screenshot option. Manually created screenshots are hidden by default and not attached to any test.
To send additional screenshots to Currents, they have to be attached to the test. For example, you can attach a screenshot to a test like this
const { test, expect } = require("@playwright/test");
test("basic test", async ({ page }, testInfo) => {
await page.goto("https://playwright.dev");
const screenshot = await page.screenshot();
await testInfo.attach("screenshot", {
body: screenshot,
contentType: "image/png",
});
});
For more information see the Playwright test info attachment documentation.
Requirements
- NodeJS 14.0.0+
- Playwright 1.22.2+