Skip to content

Create recipe "Debugging with node inspect" #2307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
24 changes: 24 additions & 0 deletions docs/recipes/debugging-with-node-inspect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Debugging tests with node-inspect

Because AVA executes its tests in parallel over multiple worker processes, it doesn't play nice with node's inspect feature by default.

If you want to use the [node inspect CLI debugger](https://nodejs.org/api/debugger.html), you can use the `profile.js` entrypoint like this:
```
node inspect ./node_modules/ava/profile.js <file>
```
Where `<file>` is the test you want to debug. It is currently only possible to debug one test file at a time.

If you want to use yarn or npm to start the debugger you can add the following script in your `package.json`:

```json
{
"scripts": {
"test:debug": "node inspect ./node_modules/ava/profile.js --"
}
}
```

You can now debug in your console using:

- npm: `npm run test:debug test/test.js`
- yarn: `yarn run test:debug test/test.js`
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ We have a growing list of [common pitfalls](docs/08-common-pitfalls.md) you may
- [Debugging tests with Chrome DevTools](docs/recipes/debugging-with-chrome-devtools.md)
- [Debugging tests with VSCode](docs/recipes/debugging-with-vscode.md)
- [Debugging tests with WebStorm](docs/recipes/debugging-with-webstorm.md)
- [Debugging tests with node-inspect](docs/recipes/debugging-with-node-inspect.md)
- [Isolated MongoDB integration tests](docs/recipes/isolated-mongodb-integration-tests.md)
- [Testing web apps using Puppeteer](docs/recipes/puppeteer.md)

Expand Down