In this sample we are going to configure VS Code for debugging Jest specs.
We will start from sample 02 Controllers.
Summary steps:
- Adding
launch.json
in VS Code. - Update
launch.json
to work with Jest.
npm install
to install previous sample packages:
npm install
Jest is running over node, so we could use VS Code for debugging jest specs:
As we know, VS Code provides by default a node debugger:
- Adding debug
launch.json
in VS Code:
IMPORTANT:
.vscode/launch.json
file is created on root path.
- Configuring launch.json to single and watchAll runs:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest single run",
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
"args": [
"-c",
"./config/test/jest.json",
"--verbose"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"type": "node",
"request": "launch",
"name": "Jest watchAll run",
"program": "${workspaceRoot}/node_modules/jest/bin/jest.js",
"args": [
"-c",
"./config/test/jest.json",
"--watchAll",
"--verbose",
"-i"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
- Now we could run specs in debugging mode.
We are an innovating team of Javascript experts, passionate about turning your ideas into robust products.
Basefactor, consultancy by Lemoncode provides consultancy and coaching services.
Lemoncode provides training services.
For the LATAM/Spanish audience we are running an Online Front End Master degree, more info: http://lemoncode.net/master-frontend