Create a debug configuration file in Visual Studio Code.
Visual studio code enables use ( sometimes with the use of extension) to debug almost any coding language (js, c#, php,ect..).
To access the Debug page we need to click the “bug” icon on the left hand menu.
Now that we have accessed the debugging page, we are able to add our configuration. To do so, click on the dropdown next to the Green arrow, like shown in the image below.
{ "version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "name": "Launch Program", "program": "${workspaceRoot}/app.js" } ] }
Setting the config
The config requires two main information. The first is the Program that we would like to run, this can actually be changed with whatever program you are currently running from the command line. When writing a command you will probably just use the name of the package ( depending how it is installed ), for example “Jasmine init”.
"${workspaceRoot}/node_modules/jasmine-es6/bin/jasmine.js"
jasmine-es6 "/tests/Tests1spec.js"
"args": [ "${workspaceFolder}\\tests\\Tests1spec.js" ]
Conclusion
The above post is aimed at supporting you and hopefully save you some time. The debugging feature of Visual Studio Code are quite extensive ( I debugger PHP in the past and it worked perfectly). Not that everything is set up, you can start debugging by clicking the green arrow in the debug page, or just by pressing F5 from your keyboard (make sure to add breakpoint where you would like the add to break).
There may be better method to debug, and most people would have webpack setup to support them in the traspilation and test run, but I wanted to go against current and try something different.
As always I am happy to receive any comment that can support the future readers.
I complete the post wit the complete file below:
{ // 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": "Launch Program", "program": "${workspaceRoot}/node_modules/Jasmine-es6/bin/jasmine.js", "args": [ "${workspaceRoot}/tests/Test1spec.js" } ] }
Thanks for this. You have a typo in your last example (“${workspaceRoon}/tests/Test1spec.js”
I should have written an unit test for it 🙂