Using tags ( Smoke, regression) with TestCafe

2.8k Views Asked by At

Using testcafe grep patterns would partially solve our problem of using tags but it would still display those tags on the spec report ...!!!

Is there a way to include tags in the test/fixture names and use grep patterns but skip those tags to be displayed in the execution report ??

import { Selector } from 'testcafe';

fixture `Getting Started`
    .page `http://devexpress.github.io/testcafe/example`;

test('My first test --tags {smoke, regression}', async t => {
    // Test code
});

test('My Second test --tags {smoke}', async t => {
    // Test code
});

test('My first test --tags {regression}', async t => {
    // Test code
});

testcafe chrome test.js -F "smoke" 

The above snippet would trigger the smoke only tests for me though but the report will display the test names along with those tags

Is there an alternative way to deal with tags or a solution to not display the tags in the test execution report?

2

There are 2 best solutions below

1
Alex Kamaev On

I think the best solution in this case is to use test/fixture metadata. Please refer the following article: http://devexpress.github.io/testcafe/documentation/test-api/test-code-structure.html#specifying-testing-metadata For now, you can't filter by metadata, but this feature is in the pull request: https://github.com/DevExpress/testcafe/pull/2841. So, after this PR is merged, you will be able to add any metadata to tests and filter by this metadata in a command line.

0
AlexS On

It appears in a recent release (v0.23.1) of testcafe you can now filter with metadata via the commandline.

You can now run only those tests or fixtures whose metadata contains a specific set of values. Use the --test-meta and --fixture-meta flags to specify these values.

testcafe chrome my-tests --test-meta device=mobile,env=production

or

testcafe chrome my-tests --fixture-meta subsystem=payments,type=regression

Read more at https://devexpress.github.io/testcafe/blog/testcafe-v0-23-1-released.html