Runner.filter Method

Allows you to select the tests to run.

filter(callback) → this
ParameterTypeDescription

callback

function(testName, fixtureName, fixturePath, testMeta, fixtureMeta)

An asynchronous callback function that determines if a test should run.

TestCafe calls the callback function for each test in the source files. Return true from the callback to include the current test or return false to exclude it.

The callback function accepts the following arguments:

ParameterTypeDescription

testName

String

The name of the test.

fixtureName

String

The name of the test fixture.

fixturePath

String

The path to the test fixture file.

testMeta

Object

Test metadata.

fixtureMeta

Object

Fixture metadata.

Note

Use the src method to specify the source files.

Related configuration file property: filter

Example

runner.filter(async (testName, fixtureName, fixturePath, testMeta, fixtureMeta) => {
    return fixturePath.startsWith('D') &&
        testName.match(someRe) &&
        fixtureName.match(anotherRe) &&
        testMeta.mobile === 'true' &&
        fixtureMeta.env === 'staging';
});