Before writing the first Jasmine test, we will need to understand the difference between a suite and a spec (test specification) in Jasmine. A Jasmine suite
is a group of test cases that can be used to test a specific behavior of the JavaScript code (a JavaScript object or function). In Jasmine, the test suite begins with a call to the Jasmine global function describe
with 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, a test case begins with a call to the Jasmine global function it
with two parameters. The first parameter represents the title of the spec and the second parameter represents a function that implements the test case.
A Jasmine spec contains one or more expectations. Every expectation represents an assertion that can be either true
or false
. In order to pass the...