What I am looking for is basically nosetest --pdb --pdb-failures
from nose testing framework.
I am using mocha for testing. What I'd like to do is to run tests like
mocha --break-on-exception --break-on-failure
that would stop executing tests once encountering exception or assertion failure, would start node-inspector for me and would allow me to introspect runninng code.
Is this possible anywhere in node.js world, with any library or test framework?
But, for me, the easier & quicker solution is to run the application in debug mode with --inspect option, with Chrome debugger to inspect it (no breakpoints), with Pause on Exceptions option enabled. That's all you need to do.
Open up Preferences > Settings and in the search box type in “node debug”. Under the Extensions tab there should be one extension titled “Node debug”. From here, click the first box: Debug > Node: Auto Attach and set the drop down to “on”. You're almost ready to go now.
To do this right-click the project in Solution Explorer/Open Command Prompt Here… Then enter: npm install mocha --save-dev. In Visual Studio, add a JavaScript Mocha Unit Test file (in Solution Explorer right-click the project/Add/New Item..). Debugging tests won't work with a regular JavaScript file.
add this line to your test:
if (global.v8debug)
global.v8debug.Debug.setBreakOnException()
start with mocha --debug-brk
, connect node-inspector, continue and wait for exception
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