Writing your first Jasmine test

Before writing our first Jasmine test, we need to understand the difference between a suite and a spec (test specification) in Jasmine. Jasmine suite is a group of test cases that can be used to test a specific behavior of the JavaScript code. In Jasmine, the test suite begins with a call to the describe Jasmine global function that has two parameters. The first parameter represents the title of the test suite, while the second parameter represents a function that implements the test suite.

A Jasmine spec represents a test case inside the test suite. In Jasmine, the test case begins with a call to the Jasmine global function it that has two parameters. The first parameter represents the title of the spec and the ...

Get JavaScript Mobile Application Development now with O’Reilly online learning.

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