Steve Quezadas Steve Quezadas - 4 months ago 22
Node.js Question

How do you set a breakpoint with node.js jasmine?

Ok, naive question here, but I am somewhat new to nodejs. I am writing a test script using jasmine. There seems to be a bug in my code, so I put "debugger" in one of the lines and jasmine is not stopping for some reason. I know it's getting to the code too, because I put a console.print command and it displays that line.

Is there something incredibly simple that I'm missing? Can't I set a breakpoint in the javascript code and get into a REPL somehow?


You probably run your Jasmine Tests like this:

$ jasmine myTest.js

Or like this:

$ ./node_modules/jasmine/bin/jasmine.js myTest.js

If you want to test node application you have many options, and as you know, jasmine is nodejs code, so you can run it in debug mode, and will run your test, so if you have debugger; in your code it will stop there.

Here are 3 simple ways to debug nodejs applications. enter link description here

You can use the first one, the build in debugger in nodejs. Run this command:

$ node debug jasmine myTest.js


$ node debug ./node_modules/jasmine/bin/jasmine.js myTest.js

Then you can press C button + Enter to continue to your debugger; brackpoint in your code...