Runner.filter Method
Allows you to select the tests to run.
filter(callback) → this
Parameter | Type | Description |
---|---|---|
|
| 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:
Parameter | Type | Description |
---|---|---|
| String | The name of the test. |
| String | The name of the test fixture. |
| String | The path to the test fixture file. |
| Object | Test metadata. |
| 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';
});