« back

Getting started with Jasmine

18 Dec 2012

Today's post will be short and sweet because getting started with Jasmine is really that easy.

If you have worked with Rspec before, you will feel right at home with jasmine. A lot of the function names have been repeated and a lot of the matchers will leave you feeling pretty comfortable as well.

Go ahead and download jasmine. If your javascript project is going be standing alone, you will create your code int the src directory and your specs in the spec folder. I do not want to get too much into the other ways and places that you can use it. I will just touch on the fact that if you want to use it with rails there is a gem.

So, once you start creating your own files, you will want to point the cool little runner to them. To do this you can open up the SpecRunner.html. Inside that file, you will find unmissable comments that say "include source files here and include spec files here". Do that. You can also remove the example ones if you want. Then you can start writing code! It really is that easy. You can look at the example files that they include with the download if you want to see a template of an actual project.

In your spec, you will start with a describe function (much like rspec) and then you can write your tests. When you want to run your specs, you can go ahead and open the SpecRunner.html in a browser.

You can find some overview documentation here and you can check out your matcher options here.

:)

comments powered by Disqus