I\'m trying to run some JavaScript code using jasmine and Resharper 7 within visual studio 2012. I follow the AMD pattern with the aid of requirejs. However, i haven\'t mana
If you use Jasmine 2.0 or newer, you can support asynchronous calls in your code. Just pass the done parameter into the function for your it unit test, then call done() when you have loaded your modules:
describe("add function", function(){
it("calls renderNew", function(done){
define("taskRenderer", [], function() {
return {
renderNew: function(){}
};
});
require(["taskRenderer"], function(taskRenderer) {
spyOn(taskRenderer, "renderNew");
taskRenderer.renderNew();
expect(taskRenderer.renderNew).toHaveBeenCalled();
done();
});
}
}
This way, you don't actually perform your test until the modules are loaded and the test doesn't prematurely get marked as finished.