Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/recipes/debugging-with-webstorm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Debugging AVA tests with WebStorm

Starting with version 2016.2, [WebStorm](https://www.jetbrains.com/webstorm/) and other JetBrains IDEs (IntelliJ IDEA Ultimate, PhpStorm, PyCharm Professional, and RubyMine with installed Node.js plugin) allow you to debug AVA tests.

## Setup

Add a new *Node.js Run/Debug configuration*: select `Edit Configurations...` from the drop-down list on the top right, then click `+` and select *Node.js*.

In the `JavaScript file` field specify the path to AVA in the project's `node_modules` folder: `node_modules/.bin/ava` on OS X and Linux or `node_modules/.bin/ava.cmd` on Windows.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@develar Unrelated, but would be nice if the user could just specify the binary name, like ava, instead of the full path, like they can in npm run script. Pretty easy to do. You can see how it's done here: https://github.com/sindresorhus/npm-run-path/blob/master/index.js

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for providing this recipe! By the way, in my version of Ava the path to the Ava executable was in node_modules/ava/cli.js.

Also (for anyone else coming after me) if your Node root isn't your Webstorm project root you'll need to update the working directory to point to the Node root.


In the `Application parameters` pass the CLI flags you're using and the test files you would like to debug, e.g. `--verbose test.js`.

Save the configuration.

## Debug

Set breakpoints in the code.

Hit the green `Debug` button next to the list of configurations on the top right. The *Debug tool window* will appear. Once the breakpoint is hit, you can evaluate variables and step through the code. When debugging multiple test files, you can switch between the processes using the dropdown in the Frames pane.