Wednesday, November 12, 2014

Javascript - Unit Testing (with Jasmine) on a browser

This post is about unit testing Javascript using Jasmine using a browser.

1. Get Jasmine here.
2. Download and unpack -- mine is in ~/app/jasmine
3. Project directory should be something like:


4. Edit the SpecRunner.html file to include the source files and the test files:


5. The test file should not run the "require" code:


6. Run the tests by viewing on the browser:

Done.

To run tests on nodejs instead of via a browser, see this earlier post.

No comments:

Post a Comment