Getting started with Jasmine

To write tests, you should create two things: test suites and specs. A spec (short for specification) is a piece of functionality that you are testing from your code; for example, if your code is calculating tax of 5% for $100.00, you would expect it to be $5. A test suite is a set of expectations that are grouped under a topic. In the preceding example, the test suite can be "Invoice totals calculation".

To start working with Jasmine, you should install it from npm, as follows:

$ npm install --save-dev jasmine

Then, you can start writing your tests. With Jasmine, you have two functions: describe() to create test suites and it() to make specs:

// specs/mathSpec.js describe('Basic mathematicfunctions', () => { it('should ...

Get Mastering Backbone.js now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.