Running Jasmine unit test with ReSharper

What would I do without ReSharper? The reason why I’m extra happy about it today is the fact that it integrates so nicely with other test runners, like Jasmine. At first, I looked at other test runners, such as Chutzpah, but I don’t want to run my unit test from a terminal.

So I downloaded Jasmine together with a sample of how it’s used (it had Song.js and Player.js together with a spec). It also contained a html file which I could browse to in order to run my tests.That is not optimal, so to my surprise I saw the little ReSharper test runner symbol next to all the jasmine unit tests

Code snippet from the jasmine sample

There was only one thing left to do in order to get these test running properly:

// Classes to test
/// <reference path="~/Scripts/jasmine-samples/Song.js"/>
/// <reference path="~/Scripts/jasmine-samples/Player.js"/>
// The Jasmine Test Framework
/// <reference path="~/Jasmine/Runner/jasmine.js"/>
/// <reference path="~/Jasmine/Runner/jasmine-html.js"/>
/// <reference path="~/Jasmine/Runner/SpecHelper.js"/>

These XML comments just refers to the files we need to run the test. The reason they weren’t there at the first place is because they were refereed in the sample HTML file.

So now when I run the unit test (Ctrl.+ R works nicely), this is what I get:

Results when running the unit tests

That means I’m all set to start writing my own javascript unit tests

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>