To test asynchronous verification of material runs() , waits() and waitsFor() :
https://github.com/pivotal/jasmine/wiki/Asynchronous-specs
Although this method looks a little ugly, as for me, so you can also consider the following options.
1. I would recommend you try jasmine.async , which allows you to write asynchronous test cases as follows:
// Run an async expectation async.it("did stuff", function(done) { // Simulate async code: setTimeout(function() { expect(1).toBe(1); // All async stuff done, and spec asserted done(); }); });
2. You can also run tests inside the require callback:
require([ 'testModule', 'anotherTestModule' ], function(testModule, anotherTestModule) { describe('My Great Modules', function() { describe('testModule', function() { it('should be defined', function() { expect(testModule).toBeDefined(); }); }); describe('anotherTestModule', function() { it('should be defined', function() { expect(anoterTestModule).toBeDefined(); }); }); }); });
3. Another point: I think this code does not work as you expect:
var test = function() { require(['testModule'], function(testModule) { return testModule + 1; }); };
Because if you call test() , it will not return you testModule + 1 .
source share