Skip to content

Commit

Permalink
Fix VSCode debugging instructions
Browse files Browse the repository at this point in the history
`configurations` is an array, not an object.

Add instructions for debugging precompiled tests.
  • Loading branch information
novemberborn committed Jan 18, 2020
1 parent 630aac3 commit 61e0d05
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions docs/recipes/debugging-with-vscode.md
Expand Up @@ -12,7 +12,7 @@ You can debug your tests using [Visual Studio Code](https://code.visualstudio.co
1. In the sidebar click the *Debug* handle.
1. Create a `launch.json` file.
1. Select the Node.js environment.
1. Add following to the `configurations` object:
1. Add following to the `configurations` array and save changes:

```json
{
Expand All @@ -32,14 +32,39 @@ You can debug your tests using [Visual Studio Code](https://code.visualstudio.co
]
}
```
1. Save your changes to the `launch.json` file.

## Using the debugger

Open the file(s) you want to debug. You can set breakpoints or use the `debugger` keyword.

Now, *with a test file open*, from the *Debug* menu run the *Debug AVA test file* configuration.

## Debugging precompiled tests

If you compile your test files into a different directory, and run the tests *from* that directory, the above configuration won't work.

Assuming the names of your test files are unique you could try the following configuration instead. This assumes the compile output is written to the `build` directory. Adjust as appropriate:


```json
{
"type": "node",
"request": "launch",
"name": "Debug AVA test file",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/ava",
"runtimeArgs": [
"debug",
"--break",
"build/**/${fileBasenameNoExtension}.*"
],
"port": 9229,
"outputCapture": "std",
"skipFiles": [
"<node_internals>/**/*.js"
]
}
```

## Serial debugging

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:
Expand Down

0 comments on commit 61e0d05

Please sign in to comment.