Friday, October 21, 2011

Jasmine-Node: Identify Failing Spec

I love jasmine-node for command-line JavaScript specs, but there's one thing I hate about it: its failure messages. The usual error output is complete line noise. No indication what spec failed, no indication of even which file the spec which failed lives in. Here's how you find that out.

I'm going to set this up as a command-line option and send a pull request later, assuming I remember, but for now, open up node_modules/jasmine-node/lib/jasmine-node/index.js. Add one line right here:

Edit: yeah, ok, fuck. Actually that didn't work. You can at least run it file-by-file, using bash and the -m command-line flag, but the regex in -m is pretty freaking primitive and literal. For instance, to run individually, I just did:

node_modules/jasmine-node/bin/jasmine-node -m foo_ --coffee spec/javascripts/node/

That underscore in foo_ is not a typo!

If you don't see a followup blog post where I explain how I fixed this, please bug me about it on Twitter. It's a good project and these are easy fixes. By the way, the reason I have spec/javascripts/node is because I also have spec/javascripts/browser. Although I like jsdom, for Backbone views, I'm running regular Jasmine in the browser, because browsers are notoriously twitchy.