Debugging tests with Visual Studio Code
Many developers consider debugging a last resort. Others would flood their code with console.log
messages. I consider debugging a productivity tool.
Debugging is trying to find bugs by running an application step by step.
We have two ways of launching our tests in debug mode. The first option is creating a JavaScript debug terminal from the Terminal tab. That will create a new terminal as we did before, but in this case, Visual Studio will enable the debugger when you run a command from that terminal:
The second option is going to the Run tab and creating a launch.json
file. You could also create that file manually inside the .vscode
folder:
Once we have the file, we can create a new configuration so that we can run npm run test
in the terminal:
{ "version": "0.2.0", ...