This is the nightmare browser provider plugin for TestCafe. It provides an electron-based, headless Chrome browser environment for running your tests in. It is popular for being more solid and reliable than phantomjs, while at the same time giving better performance.
Please note that the current implementation of electron and the underlying Chromium requires XVFB to be installed on Linux host systems, otherwise nightmare will not work (see this issue for details). This will hopefully change soon as a headless mode already landed in Chromium.
npm install testcafe-browser-provider-nightmare
When you run tests from the command line, use the provider name when specifying browsers:
testcafe nightmare 'path/to/test/file.js'
When you use API, pass the provider name to the
testCafe .createRunner() .src('path/to/test/file.js') .browsers('nightmare') .run();
It is incredibly useful to be able to see what is happening inside your browser. Nightmare's big advantage over phantomjs is that you can easily enable a visual output to aid in local debugging. The nightmare provider uses the fairly popular debug library (as does nightmare itself), so you can enable debugging with the following commandline:
DEBUG=testcafe-browser-provider-nightmare testcafe nightmare 'path/to/test/file.js'
This activates the
openDevTools options for nightmare, so the browser window becomes visible throughout the test
run and the dev tools are already opened.
NOTE: When running nightmare from a gulp task (e.g. using
child_process.spawn) you can use
process.env.DEBUG = 'testcafe-browser-provider-nightmare'; to set the debug flag in the environment, before spawning the testcafe process. Another option is to already set the variable when executing your test runner, e.g.
DEBUG=testcafe-browser-provider-nightmare gulp test