Does anyone have any idea if this is possible? Most of the sample for node-inspector seemed geared toward debugging an invoked webpage. I'd like to be able to debug jasmine-node tests though.
Open the starting file (typically index. js ), activate the Run and Debug pane, and click the Run and Debug Node. js (F5) button. The debugging screen is similar to Chrome DevTools with a Variables, Watch, Call stack, Loaded scripts, and Breakpoints list.
In short, just debug jasmine-node:
node --debug-brk node_modules/jasmine-node/lib/jasmine-node/cli.js spec/my_spec.js
If you look at the source of the jasmine-node
script, it just invokes cli.js
, and I found I could debug that script just fine.
I wanted to use node-inspector to debug a CoffeeScript test. Just adding the --coffee
switch worked nicely, e.g.
node --debug-brk node_modules/jasmine-node/lib/jasmine-node/cli.js --coffee spec/my_spec.coffee
I ended up writing a little util called toggle:
require('tty').setRawMode(true); var stdin = process.openStdin(); exports.toggle = function(fireThis) { if (process.argv.indexOf("debug")!=-1) { console.log("debug flag found, press any key to start or rerun. Press 'ctrl-c' to cancel out!"); stdin.on('keypress', function (chunk, key) { if (key.name == 'c' && key.ctrl == true) { process.exit(); } fireThis(); }); } else { console.log("Running, press any key to rerun or ctrl-c to exit."); fireThis(); stdin.on('keypress', function (chunk, key) { if (key.name == 'c' && key.ctrl == true) { process.exit(); } fireThis(); }); } }
You can drop it into your unit tests like:
var toggle = require('./toggle'); toggle.toggle(function(){ var vows = require('vows'), assert = require('assert'); vows.describe('Redis Mass Data Storage').addBatch({ ....
And then run your tests like: node --debug myfile.js debug. If you run debug toggle will wait until you anything but ctrl-c. Ctrl-c exits. You can also rerun, which is nice.
w0000t.
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