Introducing Jasmine
Jasmine is an open source framework that is used to test JavaScript code without any dependency on DOM. As Angular is loosely coupled, we can use the Jasmine framework to test Angular components, services, and so on. Independent of each other, the clean syntax of Jasmine enables you to write tests very easily.
A global function named describe is the starting point of the Jasmine function. This global function takes a function and two parameters of type string. The string parameter describes the tests, and the function will have the actual implementation of testing:
describe("short description about the test suite", function() { });
The actual test methods are defined by a global function called the it
function, which takes two arguments. The first argument is the title of the test or spec, and the second argument is the function that tests the expectations by verifying the state of the code. Expectations are similar to assert in the Microsoft unit test framework. If any...