Is it possible to debug mocha unit tests using Visual Studio Node Tools? I can run all my mocha tests using the command line command mocha . -- but debugging these unit tests is not possible at the moment. Is there any way to debug unit tests entirely within visual studio, or even at all?
It is possible to debug Mocha unit tests in NTVS in proper Visual Studio 2017. This worked fine before Nodejs v8.0.0. Since then it has had a tendency to ignore your break points.
However, in Node v10.13.0, which is the LTS version at the time of writing, the steps below do seem to work. When you install node you need to select to install the 'Tools for Native Modules' at the end of the install process, or your breakpoints may well be missed. Be warned that if you do this the node installer is likely to reboot your machine without asking you at the end of the install.
This was tested in Visual Studio 2017 15.9.1, both Enterprise and Community editions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With