Nightwatch supports running the tests in parallel in two main ways:

  • via test workers
  • by running multiple test environments in parallel

Via Workers

When this is enabled the test runner will launch a configurable number of child processes and then distribute the loaded tests over to be ran in parallel.

To enable test workers, set the test_workers top-level property, like so:

{
  "test_workers": {
    "enabled": true,
    "workers": "auto"
  }
}

or:

{"test_workers": true}


The workers option configures how many child processes can run concurrently.

  • "auto" - determined by number of CPUs e.g. 4 CPUs means 4 workers
  • {number} - specifies an exact number of workers


Another way is to pass the --parallel cli switch:

nightwatch --parallel

Test concurrency is done at the file level. Each test file will fill a test worker slot. Individual tests/steps in a test file will not run concurrently.

To improve support for displaying the output when running tests in parallel, we recommend setting detailed_output to false in your test settings (and also make sure live_output is enabled.

Multiple Environments

nightwatch -e firefox,chrome

The above will run two environments named firefox and chrome in parallel.

Terminal Output

Each environment will be run as a separate child_process and the output will be sent to the main process.

To make the output easier to read, Nightwatch by default buffers the output from each child process and displays everything at the end, grouped by environment.

If you'd like to disable the output buffering and see the output from each child process as it is sent to stdout, simply set the property "live_output" : true on the top level in your nightwatch.json (e.g. after selenium).
You can create a separate environment per browser (by chaining desiredCapabilities) and then run them in parallel. In addition, using the filter and exclude options tests can be split per environment in order to be ran in parallel.

Via Workers + Multiple Environments

It is very useful to be able to run your tests against multiple browsers in parallel and also distribute your testcases across multiple workers. From v1.7 you are able to do just that.

nightwatch -e firefox,chrome --parallel

The above will run two environments named firefox and chrome in parallel.

Improve this article