Jake
Jake

Reputation: 3028

no stack trace for jasmine-node errors

I'm using node.js and the jasmine-node npm module to run tests. This works perfectly except if the code produces an error. I get no stacktrace. For example, one of my tests only outputs this:

Error: TypeError: Cannot read property 'length' of undefined

No stack trace. This makes finding these errors so time-consuming that I'm looking for alternatives to jasmine-node.

How can I get jasmine-node to output the full stack trace with the error? The --verbose command-line flag doesn't do it.

Upvotes: 6

Views: 3599

Answers (2)

naddison
naddison

Reputation: 613

You can use jasmine-node's --captureExceptions option to output the stack trace of global exceptions.

Upvotes: 7

j pimmel
j pimmel

Reputation: 11637

Whilst I haven't used the jasmine-node npm, i have come across this kind of error before. In my experience, those sorts of errors get reported when an async loop outside the scope of your test/impl fails...

What we've done to catch all exceptions of that kind is add this code prior to execution

process.on('uncaughtException',function(e) {
    sys.log("Caught unhandled exception: " + e);
    sys.log(" ---> : " + e.stack);
});

Upvotes: 5

Related Questions