How to deal with thrown errors in async code with Jasmine?
问题 The following test causes Jasmine (2.3.4, run in browser via Karma) to crash and not run any subsequent tests it('should report as failure and continue testing', function (done) { setTimeout(function () { throw new SyntaxError('some error'); done(); }, 1000); }); How can I have this test correctly report itself as a failure and carry on with subsequent tests? 回答1: Mocking the clock will give you the expected result. Mocking the clock in general is a best practice for testing timeouts.