Hello Jasmine
Working with Jasmine is quite easy. We have to perform the following steps:
Download Jasmine 2.0 as a ZIP file from its hosting website on Github (https://github.com/pivotal/jasmine/tree/master/dist).
Create a folder for the test project.
Unzip the Jasmine package inside the folder created in step 2.
Empty the
spec
andsrc
subfolders deleting the example files.Add some source code to be tested in the
src
subfolder as.js
files.Add some testing code using Jasmine in the
spec
subfolder as.js
files.Add script references to the files added in steps 5 and 6 to the special file,
SpecRunner.html
.Open
SpecRunner.html
in a web browser to run the tests and verify the results.
This is clearly not a typical TDD coding cycle. We first write some code and then we test it. TDD suggests the exact opposite. I'm a great TDD supporter, but I want to keep things here as simple as possible and explain Jasmine even to those who do not know TDD.
For example, in step 5, we can add the following JavaScript...