This seems to be a kind of Search for the Holy Grail, but I'm looking for a setup for a JavaScript unit testing environment. The requirements are:
- testing Requirejs AMD modules
- isolate each module by mocking out dependencies
- testable in the browser during development
- testable in a headless environment for continuous integration
Everything except the headless mocking seems to be straight forward.
So far, I've tested JS-Test-Driver, Karma, and Phantomjs, and for mocking, I've used Squire and Isolate -- as well as an implementation of the code in the answer here and nothing seems to work exactly right. The main problem I keep running into again and again is that the test framework returns before all the tests have run -- primarily because the mocks need their own require()
dependencies.
Any help (or scaffold) would really help!
[edit]
I've put up a basic, working Karma project on Github with some sample mocked tests, using chai-expect as the matching library. I'll try to add more useful documentation, but if you're familiar with Karma, it should be pretty simple to extend. Just git clone
and then npm install
to get it running.