Testing in Headless Mode

TestCafe allows you to run tests in Google Chrome and Mozilla Firefox without any visible UI shell - in the headless mode (Chrome Headless, Firefox Headless). Use the headless browser parameter to launch a browser in the headless mode.

testcafe "chrome:headless" tests/sample-fixture.js
runner
    .src('tests/sample-fixture.js')
    .browsers('chrome:headless')
    .run();

Specify a path to the browser executable if you use a portable version of the browser:

testcafe "firefox:path/to/firefox:headless" tests/sample-fixture.js
runner
    .src('tests/sample-fixture.js')
    .browsers('firefox:path/to/firefox:headless')
    .run();

Note that the Take screenshot and Resize window features are fully supported in the headless mode.

Automation Port

Chrome and Firefox require a remote control port for TestCafe to attach to the browser instance. TestCafe automatically assigns a free port but you can specify a custom port via the cdpPort argument for Chrome and the marionettePort argument for Firefox.

testcafe "chrome:headless:cdpPort=9223" tests/sample-fixture.js
runner
    .src('tests/sample-fixture.js')
    .browsers('chrome:headless:cdpPort=9223')
    .run();
testcafe "firefox:headless:marionettePort=9223" tests/sample-fixture.js
runner
    .src('tests/sample-fixture.js')
    .browsers('firefox:headless:marionettePort=9223')
    .run();