In your VSCode, make sure your .vscode/launch.json
file has the following configuration:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229
}
]
}
Place a debugger;
statement in any of your tests. Then, in your project's directory, run:
node --inspect-brk node_modules/.bin/jest --runInBand
# or on Windows
node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand
Finally, go to "Run and Debug" in the Explorer, select "Attach" and click on "Start Debugging".
Also, you can watch the video tutorial here: https://www.loom.com/share/3c72296c132449a18906a4b6a7d23cc1
References: https://jestjs.io/docs/troubleshooting#debugging-in-vs-code