Playwright Tags
How to tag Playwright executions in Currents
Last updated
How to tag Playwright executions in Currents
Last updated
Note
Run-level tagging is available in @currents/playwright version 0.7.0+
Project-level and test-level tagging is available in @currents/playwright version 0.10.0+
A tag is limited to 128 characters
Using tags is a common technique for better classifying recorded test results and getting relevant insights about the test suite. Here are several examples of how software teams use tags:
manage ownership - e.g. use the team name as a tag
categorize product features - e.g. tagging onboarding
flow tests
manage tests lifecycle - e.g. tag newly introduced tests as ustable
The tags are available for producing meaningful reports, exploring metrics, narrowing down Slack notifications, filtering the results, API responses and more.
@currents/playwright version 0.10.0+ is required for test title tags
Currents parses the test titles and recognizes the conventional Playwright Tags that appear in test definitions. For example, recording the results of the following tests to Currents:
...will create a run with tags: fast
and slow
Tagging a test group (test.describe
) will "apply" the tag to every included individual test, as well as to the created run. For example, given the following test definition:
Currents will assign the following tags to the created items:
Item | Tags |
---|---|
Run |
|
| |
|
--grep
appliedIf certain tags are excluded from the execution, for example by using --grep
CLI option, only the included tests (and their tags) will be used for tagging.
It is often desired to ignore the tags included in the test title to have a consistent view of the test history or preserve the metrics.
For example, let's say you have a test named Test login page @slow
, eventually, you add another tag and the test title becomes Test login page @slow @login
. However, adding the tag will change the test name - as a result, the history of previous executions and metrics will be lost.
To remove the tags from the recorded test titles, add --pwc-remove-title-tags
CLI option or removeTitleTags
reporter configuration. Activating the removal will strip the tags from test titles (including test group names) when recording to Currents dashboard.
In the example above, Test login page @slow
and Test login page @slow @login
will be recorded as Test login page
and tags slow
+ login
will be attached to the test recording.
You can disable parsing test title tags altogether by adding --pwc-disable-title-tags
CLI option. See @currents/playwright for additional configuration options, available in versions 0.11.0+
.
@currents/playwright version 0.7.0+ is required to use run-level tags
In addition to encoding tags in test titles, you can explicitly tag the whole run (or a playwright project). There are multiple ways to explicitly tag a run.
pwc
CLI optionIf you're using pwc
executable script to run the tests, use --tag
CLI option:
You can provide a comma-separated list of tags, provide multiple --tag
options, or use both.
You can tag playwright execution by providing a list of tag
values to Currents Reporter in your playwright.config.ts
file. For example:
CURRENTS_TAG
environment variableYou can tag playwright execution by setting the CURRENTS_TAG
environment variable value to a comma-separated list of tags, for example, with @currents/playwright reporter configured:
If there are multiple definitions of run-level tags, Currents will pick the tags as follows:
Use comma-separated tags of CURRENTS_TAG
environment variable, if provided; otherwise
Use --tag
CLI option values, if provided; otherwise
Use reporter configuration values, if provided; otherwise
add no run tags
@currents/playwright version 0.10.0+ is required for project-level tags
You can tag Playwright projects by using metadata.pwc.tags
field in the project's configuration. For example, given the following Playwright project configuration:
Currents will create a run tagged with desktop
, chrome
+ all the tags extracted from individual tests.
Currents stores the recorded results as Runs, Groups, Spec Files and Tests. The items are available in the dashboard and also in responses.
Run - is a high-level abstraction that represents a CI execution of a test suite
Group - is a subset of recorded tests - representing a playwright project
Spec File - a recorded execution of tests in a file
Test Recording - a recorded execution of a test case
Each of the items can have multiple tags attached, and tagging a particular item can affect the tags of another item. When applying tags, Currents follows the rules below:
Apply explicit run-level and project-level tags "downwards" to all the included items
Apply individual test tags "upwards" to spec files, projects and runs
The table below shows the details of how the tags are applied:
Item | Tags Applied |
---|---|
Run |
|
Group/Project |
|
Spec File Recording |
|
Test Case Recording |
|
For example, given the following tests:
And adding a run-level tag runTag01
using the command: pwc ... --tag runTag01
will result in the following tags:
Item | Applied Tags |
---|---|
Run |
|
| |
|