Reputation: 43
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?
Upvotes: 3
Views: 2160
Reputation: 9475
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.
Upvotes: 1
Reputation: 5298
See this SO post for a way to debug Mocha tests using Visual Studio.
or even at all?
For a more streamlined Mocha testing debug interface, I highly recommend WebStorm as the functionality is built into the IDE. Makes debugging a breeze and has a much better UI for Mocha testing.
Upvotes: 0