The TestCafe constructor is used to create a TestCafe instance, to obtain access to the Continuous Integration API.


Creates a new TestCafe instance.

var TestCafe = require('testcafe');
var testCafe = new TestCafe(options);

options - Object. Contains startup options for TestCafe. If it is not specified, TestCafe will be unable to initialize and will terminate the process.

var options = {
    controlPanelPort: 1337,
    servicePort1: 1338,
    servicePort2: 5556,
    hostname: '',
    testsDir: 'D:\\TestCafe-14.2\\tests',
    reportsPath: 'D:\\Testing\\Reports',
    browsers: browsers

controlPanelPort - Number [0-65535]. The port number where you can access the TestCafe Control Panel UI.

servicePort1, servicePort2 - Number [0-65535]. The port numbers used by TestCafe to perform testing.

hostname - String (optional). The hostname of your computer. Used when you need to enable remote testing. If not specified, localhost is used.

testDir - String. The path to the directory where you store your tests.

reportsPath - String. The path to the directory where test-run reports will be saved.

Each test run creates a subfolder in this directory with its unique ID as a name - {reportsPath}\{reportUid}. This is where the report is saved in the JSON format. If screenshots are taken during the test run, they are stored in the {reportsPath}\{reportUid}\screenshots subfolder. If reportsPath is not specified, reports are saved to a default location that depends on the platform.

Windows: <SystemDisk>:\Users\<username>\Documents\TestCafe\reports
OSX: /Library/Application Support/TestCafe/<username>/reports
Linux: TestCafe/reports

Note that you can also specify the destination to save the report for an individual test run. To do this, pass the reportPath option to the runTests method. In this case, a copy of the report will be saved to the specified directory.

browsers - Lists all browsers that TestCafe can use for testing.

var browsers = {
    'Mozilla Firefox': {
        path: 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe',
        cmd: '-new-window -foreground'
    'Internet Explorer': {
        path: 'C:\\Program Files\\Internet Explorer\\iexplore.exe',

Keys in the browsers object ('Mozilla Firefox' and 'Internet Explorer' in the example above) are unique browser names that will be used in TestCafe UI.

path - String. The path to the executable file that starts the browser.

cmd - String (optional). Additional command line parameters.