I have read and tried different things for doing an asynchronous test in jasmine without any success. jasmine: Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL
Testing window.postMessage directive
Testing postMessage with Jasmine async doesn't work
I have the following code and i'm receiving the follow output.
Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL
describe('asynchronous tests', function () {
var value;
beforeEach(function (done) {
spyOn(myService.$rootScope, '$broadcast').and.callFake(function(){
done();
});
window.parent.postMessage({message:'event'}, '*');
});
it('Should support async execution test preparation and expectation', function(){
expect(myService.$rootScope.$broadcast).toHaveBeenCalled();
});
});
myService is defined in the parent describe function. As I understand my beforeEach should wait until the postMessage is thrown before continuing the execution but I'm getting that timeout error.
Thanks
done
:describe('asynchronous tests', function(done){
and I would move wholebeforeEach
code (spyOn
andwindow.parent
) toit
as there is only one test. – Cezary Tomczykit
, not todescribe
. :-) – Cezary Tomczyk