describe('experiments with done', ()=>{ describe('- correct usage -', ()=>{ it('should fail because of async expect failure, and failure is assigned to correct spec', (done)=>{ new Promise(function(res, rej){ setTimeout(res, 1000) }).then(()=>{ expect(1).toEqual(11) }).catch().then(done) }) it('should wait for async done call', (done)=>{ new Promise(function(res, rej){ setTimeout(res, 1000) }).then(()=>{ expect(4).toEqual(4) done() }) }) it('should wait for async done call, but fails meanwhile', (done)=>{ new Promise(function(res, rej){ setTimeout(res, 1000) }).then(()=>{ expect(4).toEqual(44) done() }) }) it('should wait for async done call, which is at the end of the promise chain', (done)=>{ new Promise(function(res, rej){ setTimeout(res, 1000) }).then(()=>{ expect(1).toEqual(1) }).catch().then(done) }) }) describe('- incorrect usage -', ()=>{ it('should fail because of async expect failure, but wont since done not used', ()=>{ new Promise(function(res, rej){ // this expect throws an error, which jasmine is handling while already processing a succeeding spec. // hence the error will be assigned to that wrong spec. setTimeout(res, 1000) }).then(()=>{ expect(2).toEqual(22) }) }) it('should fail with failed expect from previous spec', (done)=>{ // most likely the failed expectation from previous spec will be detected and reported here. new Promise(function(res, rej){ setTimeout(res, 1000) }).then(done) }) }) })