Jasmine follows the Behavioral Driven Development (BDD) framework. Before learning the working principle of Jasmine, let us know what is the BDD framework.
The following flowchart depicts the different phases of BDD framework.
Step 1 − Start
In this phase, we will make our environment ready for Jasmine application.
Step 2 − Write a failing test
In this step, we will write our first ever test case. It is obvious that this test is going to fail because there is no such file or function to be tested.
Step 3 − Write a code to make it pass
Step 4 − Refactor
Refactor is a very important phase of BDD model where we need to prepare as many test cases as we can for that particular application or function.
Step 5 − Stop
If everything is going well then your application must be ready and up. So we can consider this step as an end of our BDD application.
As the screenshot depicts we need to test Abc.js using Jasmine framework. SpecRunner.html is the output file that will take Spec.js(Test case file ), Abc.js(file to be tested), LIB as an input and run all the test cases present in the spec file and render the result into the browser.
Abc.js(File to be tested) − This is the file that contains your functionalities which will be unit tested using Spec.js and Lib file.