Skip to content

Run Debug Nightwatch tests in IntelliJ

Shruti Rathee edited this page Aug 24, 2016 · 4 revisions

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

(Skip this step if have Node.js plugin installed in your IntelliJ)

Node.js will be needed to run Nightwatch test cases. Since Node.js plugin doesn't come with IntelliJ IDE by default it will need to be added.

Add Node.js to IntelliJ

  1. Open the Settings/Preferences dialog.
  2. In the left-hand pane, select Plugins.
  3. On the Plugins page that opens in the right-hand part of the dialog, click the Install JetBrains plugin or the Browse repositories button.
  4. In the dialog that opens (the Browse JetBrains Plugins Dialog or the Browse Repositories dialog), look for Node.js and select Download and Install.
  5. Confirm your intention to download and install the selected plugin.
  6. Click Close.
  7. Click OK in the Settings dialog and restart IntelliJ IDEA for the changes to take effect.

New Configuration to run/debug test :

  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. IntelliJ 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 and environment you want to use to run test from your nightwatch.json file, e.g. "--config tests/integration/nightwatch.json -e chrome"
  9. Click Apply.

Run/Debug 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.