Skip to content

Latest commit

 

History

History
67 lines (54 loc) · 1.89 KB

debugging-with-vscode.md

File metadata and controls

67 lines (54 loc) · 1.89 KB

Debugging tests with Visual Studio Code

Translations: Français

This recipe describes the new inspect command in the upcoming AVA 3 release. See the AVA 2 documentation instead.

You can debug your tests using Visual Studio Code.

Creating a launch configuration

  1. Open a workspace for your project.
  2. In the sidebar click the Debug handle.
  3. Create a launch.json file.
  4. Select the Node.js environment.
  5. Add following to the configurations object:
{
  "type": "node",
  "request": "launch",
  "name": "Debug AVA test file",
  "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/ava",
  "runtimeArgs": [
    "debug",
    "--break",
    "${file}"
  ],
  "port": 9229,
  "outputCapture": "std",
  "skipFiles": [
    "<node_internals>/**/*.js"
  ]
}
  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.

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:

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

Note that, if your tests aren't properly isolated, certain test failures may not appear when running the tests serially.