Almad
Almad

Reputation: 5893

Is there a way to start debugger on exception or test failure in node.js?

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?

Upvotes: 5

Views: 1184

Answers (1)

Andrey Sidorov
Andrey Sidorov

Reputation: 25446

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

Upvotes: 5

Related Questions