Debugging in VSCode - rquellh/testcafe-cucumber GitHub Wiki
My editor of choice is VSCode for being lighter than a traditional IDE but a little more than a text editor. It can be frustrating setting up the debugger, hopefully the
Setting up the launch.json file
- If you don't already have this, create a folder in the root directory called
.vscode - Create a file under the
.vscodefolder calledlaunch.json

- Copy and paste the following code into the
launch.jsonfile
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug",
"runtimeExecutable": "npm.cmd",
"cwd": "${workspaceRoot}",
"env":{
"NODE_PATH": "${workspaceRoot}/node_modules"
},
"runtimeArgs": [
"run-script", "debug"
],
"port": 1337
}
]
}
Setting up the package.json script
You probably already have this script in the package.json file but let's make sure
- Open the
package.jsonfile in the root directory - Under
"scripts"make sure you have the following code for"debug"
"scripts": {
"debug": "node --inspect=1337 --debug-brk --nolazy node_modules/cucumber/bin/cucumber-js --tags @debug --format json:./reports/report.json"
}
Using debugging
You should be all set. Let's try out debugging.
- For the script I created I tag the scenario that I'm debugging, so all of my tests don't run just the test that I want to debug runs.

- Select debug in the left pane

- You should see the "Debug" in the configuration dropdown

- Now set a breakpoint at the point in the code that is you are trying to learn more about

- Click the green arrow next to the configuration dropdown
