Runner Object

An object that configures and launches test tasks.

Use the testCafe.createRunner method to create a Runner.

The following methods configure test runner settings required to start tests:

Method Description
browsers Specifies the browsers in which tests run.
src Configures the test runner to run tests from the specified locations.

You can also use the following methods to configure other options:

Method Description
clientScripts Injects scripts into pages visited during the tests.
concurency Specifies that tests should run concurrently.
filter Allows you to select the tests to run.
reporter Configures how TestCafe generates test run reports.
screenshots Specifies how TestCafe should take screenshots of the tested pages.
startApp Specifies a shell command that is executed before TestCafe runs tests.
tsConfigPath Enables TestCafe to use a custom TypeScript configuration file and specifies its location.
useProxy Specifies the proxy server used in your local network to access the Internet.
video Enables TestCafe to record videos of test runs.

Call the runner.run method after the configuration methods to run tests.

You can stop all test runs with the runner.stop method.

Example

const createTestCafe = require('testcafe');

const testcafe = await createTestCafe('localhost', 1337, 1338);

try {
    const runner = testcafe.createRunner();

    const failedCount = await runner
        .src(['tests/fixture1.js', 'tests/func/fixture3.js'])
        .browsers(['chrome', 'safari'])
        .run();

    console.log('Tests failed: ' + failedCount);
}
finally {
    await testcafe.close();
}