I\'m using Jasmine 2.1. I am trying to use Jasmine 2.1 to test a module. One of my modules has a function that executes code asynchronously. I need to test the result of the
I would recommend taking a look at the async section of the jasmine docs. So, with this information we can use a done
callback to wait for the execution to finish before testing anything, like this:
var MyModule= require('./myModule');
describe("My Module", function() {
var myModule = new MyModule();
it('Execute', function(done) {
myModule.execute(function(){
expect(myModule.state).toBe('Executed');
done();
});
});
});