This section describes the API that allows you to run TestCafe tests from your Node.js modules.
const createTestCafe = require('testcafe'); const testCafe = await createTestCafe('localhost', 1337, 1338);
const remoteConnection = await testcafe.createBrowserConnection(); const runner = testcafe.createRunner();
Remote browser connections allow you to run tests on remote devices.
The test runner configures and launches test tasks.
The following example shows how to run tests from the
myFixture.js fixture in two browsers:
Google Chrome installed locally and another browser (that can be any of the supported browsers) on a remote device.
The test run report will be output in the JSON format.
const failedCount = await runner .src('tests/myFixture.js') .browsers([remoteConnection, 'chrome']) .reporter('json') .run();
For details, see the reference topics below.