Created
April 4, 2014 14:31
-
-
Save cmlenz/9975826 to your computer and use it in GitHub Desktop.
Can’t get even the simplest AngularJS async test to work with Karma, tried both Jasmine 2.0 and Mocha. It works when I remove the ngMock module() invocation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('myModule', []); | |
describe('Async', function() { | |
beforeEach(function(done) { | |
console.log("beforeEach", done); | |
module('myModule', function() { // <- hangs here | |
console.log("got module"); | |
setTimeout(function() { | |
done(); | |
}, 100); | |
}); | |
}); | |
it("should run", function(done) { | |
console.log("test", done); | |
setTimeout(function() { | |
done(); | |
}, 100); | |
}); | |
afterEach(function(done) { | |
console.log("test", done); | |
setTimeout(function() { | |
done(); | |
}, 100); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEBUG [karma]: All browsers are ready, executing | |
DEBUG [web-server]: serving: .../node_modules/karma/static/context.html | |
DEBUG [web-server]: serving (cached): async_mocha.spec.js | |
LOG: 'beforeEach', function (err){ ... } | |
Firefox 28.0.0 (Mac OS X 10.9) Async "before each" hook FAILED | |
timeout of 2000ms exceeded | |
Runnable.prototype.resetTimeout/this.timer<@.../node_modules/mocha/mocha.js:4254 | |
LOG: 'test', function (err){ ... } | |
Firefox 28.0.0 (Mac OS X 10.9): Executed 1 of 1 (1 FAILED) ERROR (2.116 secs / 2.002 secs) |
Yes, subtly. Got it working here: https://gist.github.com/cmlenz/9978669 – although in a "real" example.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hmm, maybe I misunderstood the ngMock module() fn.