FYI to debug using nodeunit (useful if you want to debug any npm packages that use it for their unit tests), you have to modify the nodeunit.cmd file. Nodeunit blindly grabs all arguments when it first runs including the arguments to node. Since Nodejstools
passes --debug-brk as the last parameter, Nodeunit tries to pick it up. So we must modify the nodeunit.cmd file to move the --debug-brk as the first parameter.
Modify your C:\Users\YOURUSERNAME\AppData\Roaming\npm\nodeunit.cmd to this:
(*or if you don't want to modify the nodeunit.cmd file then create a new file called nodeunitdebug.cmd in the same directory and use that for your Node.exe path):
if "%~1" neq "" (
echo found arg: %~1
if /i "%~1" neq "--debug-brk" (
set args=%args% %1
if /i "%~1" equ "--debug-brk" (
if defined args set args=%args:~1%
@IF EXIST "%workingdir%\node.exe" (
"%workingdir%\node.exe" %debugbrk% "%workingdir%\node_modules\nodeunit\bin\nodeunit" %args%
) ELSE (
node %debugbrk% "%workingdir%\node_modules\nodeunit\bin\nodeunit" %args%
if /i "%pausewhendone%" equ "true" (
Then use these project settings:
- Node.exe path: C:\Users\John\AppData\Roaming\npm\nodeunit.cmd
- Node.exec arguments: blank
- Script arguments: PATH TO YOUR UNIT TEST DIRECTORY GOES HERE
- Working directory: .
- Environment Variables: pausewhendone=true (NOTE: Set this if you want the unit test results to pause when done so you can read the results, otherwise leave it blank)
Also something to keep in mind. To get around the 256-character limit, I use a symbolic link to shorten the path and load my visual studio project from the symbolic link (you have to launch it from a command window or Visual Studio will resolve the full path).
Debugging doesn't work, though, because it somehow "resolves" to the real path name and the breakpoints look like they are set in an external unused file.
To get around this, you would move your project to a directory that has a short path, and then create a symbolic link to that directory in the old project location.