Wednesday, July 24, 2013

Setting up Jasmine for JavaScript tests

Testing your JavaScript with Jasmine is A Good Thing, so I figured it would be easy to get started. There's great documentation at the Github/Jasmine site as to how the tests are described and what matchers are available, but there didn't seem to be any clear-cut instructions on how to get the whole thing to run once you've installed it. There's talk of a file 'SpecRunner.html' and there were a number of posts asking "Where's my SpecRunner file?". And even after you install the gem, there's no documentation provided with rake -T to tell you what to do.

Turns out it's really drop-dead simple so - just in case someone else has this problem - here's what I did.
cd /path/to/your/project
gem install jasmine
rake jasmine
http://localhost:8888 in your browser
The tests in your project are run automatically.

No comments:

Post a Comment