You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use [inspect-process](https://github.com/jaridmargolin/inspect-process) to easily launch a debugging session with Chrome DevTools.
5
+
**This recipe describes the new `inspect` command in the upcoming AVA 3 release. See the [AVA 2](https://github.com/avajs/ava/blob/v2.4.0/docs/recipes/debugging-with-chrome-devtools.md) documentation instead.**
6
+
7
+
You can debug your tests using [Chrome DevTools](https://developers.google.com/web/tools/chrome-devtools).
8
+
9
+
Open Chrome, then navigate to <chrome://inspect/>. Click the *Open dedicated DevTools for Node* link within the *Devices* section.
10
+
11
+
In the *DevTools for Node* window, navigate to *Sources* and in the left-hand column select *Filesystem*. Add your project directory to the workspace. Make sure to grant permission.
12
+
13
+
Now run a specific test file:
6
14
7
15
```console
8
-
$ npm install --global inspect-process
16
+
npx ava debug test.js
9
17
```
10
18
19
+
The DevTools should connect automatically and your tests will run. Use DevTools to set breakpoints, or use the `debugger` keyword.
20
+
21
+
Run with the `--break` option to ensure the DevTools hit a breakpoint right before the test file is loaded:
Add a new configuration in the dropdown menu next to the green `Debug` button: `Add configuration`. This will open `launch.json` with all debug configurations.
> **Note:** The file you want to debug, must be open and active
33
-
34
-
> **Note:** The breakpoints in VSCode are a bit buggy sometimes (especially with async code). `debugger;` always works fine.
35
-
36
-
Set breakpoints in the code **or** write `debugger;` at the point where it should stop.
37
-
38
-
Hit the green `Debug` button next to the list of configurations on the top left in the `Debug` view. Once the breakpoint is hit, you can evaluate variables and step through the code.
5
+
**This recipe describes the new `inspect` command in the upcoming AVA 3 release. See the [AVA 2](https://github.com/avajs/ava/blob/v2.4.0/docs/recipes/debugging-with-vscode.md) documentation instead.**
6
+
7
+
You can debug your tests using [Visual Studio Code](https://code.visualstudio.com/).
Open the file(s) you want to debug. You can set breakpoints or use the `debugger` keyword.
40
+
41
+
Now, *with a test file open*, from the *Debug* menu run the *Debug AVA test file* configuration.
39
42
40
43
## Serial debugging
41
44
42
45
By default AVA runs tests concurrently. This may complicate debugging. Add a configuration with the `--serial` argument so AVA runs only one test at a time:
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.
0 commit comments