Sometime testing our JavaScript code becomes a tough task. Jasmine is a behavior-driven development framework for testing our JavaScript code. It does not depend on any other JavaScript frameworks. It does not require a DOM. And it has a clean syntax which makes you easily write the tests. You can find the Jasmine documentation here and the project in GitHub.
A spy is defined as a test specific function which intercepts calls to an underlying function in the application code and dispatches its own implementation when the underlying function is called to test the interface rather than the implementation.
There are some terms you must be aware of before going to write the Jasmine test cases.
A suit is the starting point of a Jasmine test cases, it actually calls the global jasmine function describe. It can have two parameters, a string value which describes the suit, and a function which implements the suit.
Like suites, a spec starts with a string which can be the title of the suit and a function where we write the tests. A spec can contain one or more expectation that test the state of our code.
Value of an expectation is either true or false, an expectation starts with the function expect. It takes a value and call the actual one.