Majorly, Jasmine is made up of three functions
- assertions (expect)
Like standard frameworks, it also has setup method and tear down methods
- beforeEach() – Setup Method
- afterEach() – Teardown Method
For the sake of simplicity of post, I would not discuss much in detail. However, you can navigate to official Jasmine guide for deep dive.
You can download latest version of Jasmine from here. Once downloaded, you can extract and save lib folder in your project.
Its time to see how we can write a test method using Jasmine Framework.
Above code snippet shows how we are using describe, it and expect methods provided by Jasmine framework.
Below is our files and folders structure
Below is the output of our example. As all test passed, we don’t see any error
In case, if some method fails test execution, then it would show error report like below image
First 25 minutes of below video is basics of Jasmine Test Framework with same example as of this post.