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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.