-
Notifications
You must be signed in to change notification settings - Fork 59
Debugging in VSCode
rquellh edited this page May 18, 2018
·
10 revisions
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
- If you don't already have this, create a folder in the root directory called
.vscode
- Create a file under the
.vscode
folder calledlaunch.json
- Copy and paste the following code into the
launch.json
file
{
// 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
}
]
}
You probably already have this script in the package.json
file but let's make sure
- Open the
package.json
file 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"
}
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