I can do:
But how to debug nodeunit test using node inspector?
I tried, but not working:
nodeunit --debug myNodeUnitModule_test.js
It's not working.nodebug /usr/local/bin/nodeunit myNodeunit_test.js
But it's not working neither on ubuntu (No such file or directory
) nor on mac (env: node\r: No such file or directory
)Almost works node --debug /usr/local/bin/nodeunit ./routes/edit/bodyTelInfoArraysToObject_test.js
where /usr/local/bin/nodeunit
is path taken by command which nodeunit
got output:
debugger listening on port 5858
and test executed there.
But I can't jump in debuggin: when I open url localhost:8080
in chrome to watch debugging:
On my nodeunit test I wrote debugger
to stop on debug there.
But nothing.
In your tests insert debugger;
command
exports['Main test'] = function(test){
debugger;
test.expect(1);
test.ok(true, 'Must be ok');
test.done();
};
And start all this
$ node --debug-brk `which nodeunit` test.js
Now in browser press F8, then F10, and you are right on the next line after first debugger;
command in your test.
But I prefer to start everything with node-supervisor, that restart test automatically when test finished or files in project directory changed:
$ npm -g install supervisor node-inspector
$ # console 1
$ # supervisor restarts node-inspector when it quits
$ # ignores file changes
$ supervisor -i . -x node-inspector .
$ # console 2
$ supervisor --debug-brk -- `which nodeunit` test/index.js