Book Image

WEB APP TESTING USING KNOCKOUT.JS

By : Roberto Messora
Book Image

WEB APP TESTING USING KNOCKOUT.JS

By: Roberto Messora

Overview of this book

Table of Contents (11 chapters)

Hello Jasmine


Working with Jasmine is quite easy. We have to perform the following steps:

  1. Download Jasmine 2.0 as a ZIP file from its hosting website on Github (https://github.com/pivotal/jasmine/tree/master/dist).

  2. Create a folder for the test project.

  3. Unzip the Jasmine package inside the folder created in step 2.

  4. Empty the spec and src subfolders deleting the example files.

  5. Add some source code to be tested in the src subfolder as .js files.

  6. Add some testing code using Jasmine in the spec subfolder as .js files.

  7. Add script references to the files added in steps 5 and 6 to the special file, SpecRunner.html.

  8. 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...