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.
Showing posts with label Jasmine. Show all posts
Showing posts with label Jasmine. Show all posts
Wednesday, November 12, 2014
Javascript - Unit Testing (with Jasmine) using NodeJS
Here's how to implement unit testing (with Jasmine and Node) for a class defined earlier:
Source files in subfolder "src" and test files in subfolder "spec". All test files must end with ".spec.js". Execute the test like so:
Done.
To run tests via a browser instead, see this other post.
Source files in subfolder "src" and test files in subfolder "spec". All test files must end with ".spec.js". Execute the test like so:
Done.
To run tests via a browser instead, see this other post.
Subscribe to:
Posts (Atom)





