Javascript测试框架Jasmine(六):异步代码测试
测试报告会自动追加到页尾,这个是异步测试,要等5s
describe("Jasmine 异步测试演示", function() { var value; beforeEach(function(done) { setTimeout(function() { value = 0; done(); }, 1); }); it("should support async execution of test preparation and expectations", function(done) { value++; expect(value).toBeGreaterThan(0); done(); }); describe("5秒钟", function() { var originalTimeout; beforeEach(function() { originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; jasmine.DEFAULT_TIMEOUT_INTERVAL = 6000; }); it("takes a long time", function(done) { setTimeout(function() { done(); }, 5000); }); afterEach(function() { jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; }); }); });