description |
---|
Setting up Current Actions for your Playwright Project |
- Only available for Playwright
- Requires
@currents/playwright
v1.9.0+
Setting up the Currents Actions consists of 3 steps:
- Setting up the project
- Configuring Playwright fixtures
- Updating the tests code
{% hint style="info" %} Check out the example GitHub repository. {% endhint %}
Install and configure Currents reporter following you-first-playwright-run.md guide.
@currents/playwright
provides a Playwright fixture that must be installed to enable Currents fixtures.
{% hint style="info" %}
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 playwright-fixtures.md for more information.
{% endhint %}
{% code title="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.actionFixtures,
});
{% endcode %}
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";
After extending the test
method, many Currents fixtures are enabled by default. If you wish to only conditionally enable them (such as only in CI) you can use the currentsFixturesEnabled
property in your playwright.config.ts
file.
{% code title="playwright.config.ts" %}
// ...
use: {
...
currentsFixturesEnabled: !!process.env.CI,
},
{% endcode %}