MontageJS uses some pure unit tests that are straightforward Jasmine specs.
To install the test code, run npm install
in your project folder. This installs the montage-testing package, which adds some useful utilities for writing jasmine tests. You will need the file run-tests.html.
For an example of how we implement unit testing, see the digit repository:
- run-tests loads our test environment.
data-module="all"
inside the final script tag tells the system to load test/all.js.- all.js specifies a list of module ids for the runner to execute.
Note that in this example, all the tests load a page in an iframe using
TestPageLoader.queueTest()
. These are akin to integration tests since they test the component in a real environment.
We also test some components by mocking their dependencies.
Tests are in the test
directory. Use npm test
to run the tests in
NodeJS or open test/run.html
in a browser.
To run the tests in your browser, simply use npm run test:jasmine
.
To run the tests using Karma use npm run test:karma
and for continious tests run with file changes detection npm run test:karma-dev
.