diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 404e96ef..cc918da0 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -602,7 +602,7 @@ getJasmineRequireObj().Env = function(j$) { var queueRunnerFactory = function(options) { options.catchException = catchException; options.clearStack = options.clearStack || clearStack; - options.timer = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout}; + options.timeout = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout}; options.fail = self.fail; new j$.QueueRunner(options).execute(); @@ -1727,7 +1727,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { this.onException = attrs.onException || function() {}; this.catchException = attrs.catchException || function() { return true; }; this.userContext = attrs.userContext || {}; - this.timer = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout}; + this.timeout = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout}; this.fail = attrs.fail || function() {}; } @@ -1767,7 +1767,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { function attemptAsync(queueableFn) { var clearTimeout = function () { - Function.prototype.apply.apply(self.timer.clearTimeout, [j$.getGlobal(), [timeoutId]]); + Function.prototype.apply.apply(self.timeout.clearTimeout, [j$.getGlobal(), [timeoutId]]); }, next = once(function () { clearTimeout(timeoutId); @@ -1781,7 +1781,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { }; if (queueableFn.timeout) { - timeoutId = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() { + timeoutId = Function.prototype.apply.apply(self.timeout.setTimeout, [j$.getGlobal(), [function() { var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'); onException(error, queueableFn); next(); diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index cb199586..1a7bc263 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -861,6 +861,36 @@ describe("Env integration", function() { env.execute(); }); + it("should not use the mock clock for asynchronous timeouts", function(){ + var env = new j$.Env(), + reporter = jasmine.createSpyObj('fakeReporter', [ "specDone", "jasmineDone" ]), + clock = env.clock; + + reporter.jasmineDone.and.callFake(function() { + expect(reporter.specDone.calls.count()).toEqual(1); + expect(reporter.specDone.calls.argsFor(0)[0]).toEqual(jasmine.objectContaining({status: 'passed'})); + }); + + env.addReporter(reporter); + j$.DEFAULT_TIMEOUT_INTERVAL = 5; + + env.beforeAll(function() { + clock.install(); + }); + + env.afterAll(function() { + clock.uninstall(); + }); + + env.it("spec that should not time out", function(done) { + clock.tick(6); + expect(true).toEqual(true); + done(); + }); + + env.execute(); + }); + it("should wait the specified interval before reporting an afterAll that fails to call done", function(done) { var env = new j$.Env(), reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone','suiteDone']); diff --git a/src/core/Env.js b/src/core/Env.js index def82860..0bd0d1d8 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -169,7 +169,7 @@ getJasmineRequireObj().Env = function(j$) { var queueRunnerFactory = function(options) { options.catchException = catchException; options.clearStack = options.clearStack || clearStack; - options.timer = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout}; + options.timeout = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout}; options.fail = self.fail; new j$.QueueRunner(options).execute(); diff --git a/src/core/QueueRunner.js b/src/core/QueueRunner.js index a4d24603..e7086330 100644 --- a/src/core/QueueRunner.js +++ b/src/core/QueueRunner.js @@ -17,7 +17,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { this.onException = attrs.onException || function() {}; this.catchException = attrs.catchException || function() { return true; }; this.userContext = attrs.userContext || {}; - this.timer = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout}; + this.timeout = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout}; this.fail = attrs.fail || function() {}; } @@ -57,7 +57,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { function attemptAsync(queueableFn) { var clearTimeout = function () { - Function.prototype.apply.apply(self.timer.clearTimeout, [j$.getGlobal(), [timeoutId]]); + Function.prototype.apply.apply(self.timeout.clearTimeout, [j$.getGlobal(), [timeoutId]]); }, next = once(function () { clearTimeout(timeoutId); @@ -71,7 +71,7 @@ getJasmineRequireObj().QueueRunner = function(j$) { }; if (queueableFn.timeout) { - timeoutId = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() { + timeoutId = Function.prototype.apply.apply(self.timeout.setTimeout, [j$.getGlobal(), [function() { var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'); onException(error, queueableFn); next();