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

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

Via test 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:

nightwatch.json
{
  "test_workers": {
    "enabled": true,
    "workers": "auto"
  }
}

or:

nightwatch.json
{"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 --workers CLI switch which accept the number of desired parallel processes, e.g.:
nightwatch --workers=4

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 supports running tests across multiple browsers in parallel. The below command will run two environments named firefox and chrome in parallel:

nightwatch --env firefox,chrome

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 --workers=4

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