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.jsonin VS Code. - Update
launch.jsonto work with Jest.
npm installto install previous sample packages:
npm installJest 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.jsonin VS Code:
IMPORTANT:
.vscode/launch.jsonfile 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
