Debugging Nightwatch tests in WebStorm

gwcgm1 edited this page Oct 13, 2016 · 7 revisions

You can setup Nightwatch to debug through WebStorm IDE. Here's how to do this:

Create New Configuration

  1. Click Run in the main toolbar
  2. Edit Configurations
  3. On the top left of the Run/Debug Configurations dialog, click the + sign.
  4. Choose Node.js
  5. Name the new configuration "Nightwatch"
  6. WebStorm should detect your node interpreter (probably in /usr/local/bin/node)
  7. Under "JavaScript file" enter node_modules/nightwatch/bin/runner.js
  8. Under "Application parameters" enter the config switch with the path to your nightwatch.json, e.g. "--config tests/integration/nightwatch.json"
  9. Click Apply.

Run Tests

  1. Click Run
  2. Debug "Nightwatch"

-- Debugging tests is not supported when running in parallel, since a test worker is a separate node process.

-- You can run or debug a single file through WebStorm using the context menu. For this to work with Nightwatch you need to change the config setup you have for the default Node.js (and can get rid of the Nightwatch config if you want too).

Debug/Run a single nightwatch test

  1. Edit the default Node.js config
  2. Put all values in the "Node parameters" field instead, for example C:\Users\tester\AppData\Roaming\npm\node_modules\nightwatch\bin\runner.js --config "D:\git\mytests\nightwatch.json" --env chrome
  3. Set the working directory to the location of your nightwatch/tests folder

From now on you can right click on a file in WebStorm to bring up the context menu and run/debug the individual file.