Applying Rules to Runs

Learn how to enable the Currents Automation Rules to influence runs

  • This feature is in beta

Currents allows you to define Rules from the dashboard, that can apply actions during Playwright test runs.

The following actions are supported when a rule matches:

  • Skip Test - Playwright will not run the test at all

  • Quarantine Test - Playwright will run the test, but will ignore any reported failures

Setting up the rule engine to apply while running your Playwright tests consists of 3 steps:

  1. Setting up the project

  2. Configuring Playwright Rules fixtures

  3. Updating the tests code

  4. Creating rules in Currents dashboard

Setting up the Currents Reporter

Requires @currents/playwright v1.9.0+

Install and configure Currents reporter following Your First Playwright Run. Make sure that @currents/playwright reporter is configured with the right Record Key and Project ID.

Playwright Fixtures for Rules Engine

@currents/playwright provides a Playwright fixture for applying the actions from matched rules.

It is a good practice to extend the default Playwright test method, for example to enable Page Object Model, sharing a state between multiple tests etc. See Currents Playwright fixtures for more information.

base.ts
 import {
   CurrentsFixtures,
   CurrentsWorkerFixtures,
   fixtures,
 } from "@currents/playwright";
 import { test as base } from "@playwright/test";
 
 export const test = base.extend<CurrentsFixtures, CurrentsWorkerFixtures>({
   ...fixtures.baseFixtures,
   ...fixtures.rulesFixtures,
 });

Update tests to use new test method

Import and use the extended test for every test case to enable the rules engine for that test.

import { expect } from "@playwright/test";
import { test } from "./base.ts";

Any rules that match your test will now automatically apply.

Creating Rules in Currents Dashboard

Last updated