Merge branch 'ikonst-set-timeout-error-message'
- Merges #1567 from @ikonst
This commit is contained in:
@@ -1453,7 +1453,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
userContext: function() { return suite.clonedSharedUserContext(); },
|
userContext: function() { return suite.clonedSharedUserContext(); },
|
||||||
queueableFn: {
|
queueableFn: {
|
||||||
fn: fn,
|
fn: fn,
|
||||||
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
|
timeout: timeout || 0
|
||||||
},
|
},
|
||||||
throwOnExpectationFailure: throwOnExpectationFailure
|
throwOnExpectationFailure: throwOnExpectationFailure
|
||||||
});
|
});
|
||||||
@@ -1536,7 +1536,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach');
|
ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach');
|
||||||
currentDeclarationSuite.beforeEach({
|
currentDeclarationSuite.beforeEach({
|
||||||
fn: beforeEachFunction,
|
fn: beforeEachFunction,
|
||||||
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
|
timeout: timeout || 0
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1545,7 +1545,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll');
|
ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll');
|
||||||
currentDeclarationSuite.beforeAll({
|
currentDeclarationSuite.beforeAll({
|
||||||
fn: beforeAllFunction,
|
fn: beforeAllFunction,
|
||||||
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
|
timeout: timeout || 0
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1555,7 +1555,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
afterEachFunction.isCleanup = true;
|
afterEachFunction.isCleanup = true;
|
||||||
currentDeclarationSuite.afterEach({
|
currentDeclarationSuite.afterEach({
|
||||||
fn: afterEachFunction,
|
fn: afterEachFunction,
|
||||||
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
|
timeout: timeout || 0
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1564,7 +1564,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
ensureIsFunctionOrAsync(afterAllFunction, 'afterAll');
|
ensureIsFunctionOrAsync(afterAllFunction, 'afterAll');
|
||||||
currentDeclarationSuite.afterAll({
|
currentDeclarationSuite.afterAll({
|
||||||
fn: afterAllFunction,
|
fn: afterAllFunction,
|
||||||
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
|
timeout: timeout || 0
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -5090,12 +5090,16 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
|
|
||||||
self.globalErrors.pushListener(handleError);
|
self.globalErrors.pushListener(handleError);
|
||||||
|
|
||||||
if (queueableFn.timeout) {
|
if (queueableFn.timeout !== undefined) {
|
||||||
|
var timeoutInterval = queueableFn.timeout || j$.DEFAULT_TIMEOUT_INTERVAL;
|
||||||
timeoutId = self.setTimeout(function() {
|
timeoutId = self.setTimeout(function() {
|
||||||
var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.');
|
var error = new Error(
|
||||||
|
'Timeout - Async callback was not invoked within ' + timeoutInterval + 'ms ' +
|
||||||
|
(queueableFn.timeout ? '(custom timeout)' : '(set by jasmine.DEFAULT_TIMEOUT_INTERVAL)')
|
||||||
|
);
|
||||||
onException(error);
|
onException(error);
|
||||||
next();
|
next();
|
||||||
}, queueableFn.timeout());
|
}, timeoutInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ describe("QueueRunner", function() {
|
|||||||
|
|
||||||
it("sets a timeout if requested for asynchronous functions so they don't go on forever", function() {
|
it("sets a timeout if requested for asynchronous functions so they don't go on forever", function() {
|
||||||
var timeout = 3,
|
var timeout = 3,
|
||||||
beforeFn = { fn: function(done) { }, type: 'before', timeout: function() { return timeout; } },
|
beforeFn = { fn: function(done) { }, type: 'before', timeout: timeout },
|
||||||
queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' },
|
queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' },
|
||||||
onComplete = jasmine.createSpy('onComplete'),
|
onComplete = jasmine.createSpy('onComplete'),
|
||||||
onException = jasmine.createSpy('onException'),
|
onException = jasmine.createSpy('onException'),
|
||||||
@@ -304,7 +304,7 @@ describe("QueueRunner", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("continues running functions when an exception is thrown in async code without timing out", function() {
|
it("continues running functions when an exception is thrown in async code without timing out", function() {
|
||||||
var queueableFn = { fn: function(done) { throwAsync(); }, timeout: function() { return 1; } },
|
var queueableFn = { fn: function(done) { throwAsync(); }, timeout: 1 },
|
||||||
nextQueueableFn = { fn: jasmine.createSpy("nextFunction") },
|
nextQueueableFn = { fn: jasmine.createSpy("nextFunction") },
|
||||||
onException = jasmine.createSpy('onException'),
|
onException = jasmine.createSpy('onException'),
|
||||||
globalErrors = { pushListener: jasmine.createSpy('pushListener'), popListener: jasmine.createSpy('popListener') },
|
globalErrors = { pushListener: jasmine.createSpy('pushListener'), popListener: jasmine.createSpy('popListener') },
|
||||||
|
|||||||
@@ -1106,17 +1106,15 @@ describe("Env integration", function() {
|
|||||||
|
|
||||||
it('should wait a custom interval before reporting async functions that fail to call done', function(done) {
|
it('should wait a custom interval before reporting async functions that fail to call done', function(done) {
|
||||||
var env = createMockedEnv(),
|
var env = createMockedEnv(),
|
||||||
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone', 'suiteDone', 'specDone']),
|
reporter = jasmine.createSpyObj('fakeReport', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
timeoutFailure = (/^Error: Timeout - Async callback was not invoked within timeout specified by jasmine\.DEFAULT_TIMEOUT_INTERVAL\./);
|
|
||||||
|
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function(r) {
|
reporter.jasmineDone.and.callFake(function(r) {
|
||||||
expect(r.failedExpectations).toEqual([]);
|
expect(r.failedExpectations).toEqual([]);
|
||||||
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('suite beforeAll', [ timeoutFailure ]);
|
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('suite beforeAll', [ 'Error: Timeout - Async callback was not invoked within 5000ms (custom timeout)' ]);
|
||||||
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('suite afterAll', [ timeoutFailure ]);
|
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('suite afterAll', [ 'Error: Timeout - Async callback was not invoked within 2000ms (custom timeout)' ]);
|
||||||
expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite beforeEach times out', [ timeoutFailure ]);
|
expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite beforeEach times out', ['Error: Timeout - Async callback was not invoked within 1000ms (custom timeout)']);
|
||||||
expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite afterEach times out', [ timeoutFailure ]);
|
expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite afterEach times out', [ 'Error: Timeout - Async callback was not invoked within 4000ms (custom timeout)' ]);
|
||||||
expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite it times out', [ timeoutFailure ]);
|
expect(reporter.specDone).toHaveFailedExpectationsForRunnable('suite it times out', [ 'Error: Timeout - Async callback was not invoked within 6000ms (custom timeout)' ]);
|
||||||
|
|
||||||
jasmine.clock().tick(1);
|
jasmine.clock().tick(1);
|
||||||
realSetTimeout(done);
|
realSetTimeout(done);
|
||||||
|
|||||||
+5
-5
@@ -682,7 +682,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
userContext: function() { return suite.clonedSharedUserContext(); },
|
userContext: function() { return suite.clonedSharedUserContext(); },
|
||||||
queueableFn: {
|
queueableFn: {
|
||||||
fn: fn,
|
fn: fn,
|
||||||
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
|
timeout: timeout || 0
|
||||||
},
|
},
|
||||||
throwOnExpectationFailure: throwOnExpectationFailure
|
throwOnExpectationFailure: throwOnExpectationFailure
|
||||||
});
|
});
|
||||||
@@ -765,7 +765,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach');
|
ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach');
|
||||||
currentDeclarationSuite.beforeEach({
|
currentDeclarationSuite.beforeEach({
|
||||||
fn: beforeEachFunction,
|
fn: beforeEachFunction,
|
||||||
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
|
timeout: timeout || 0
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -774,7 +774,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll');
|
ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll');
|
||||||
currentDeclarationSuite.beforeAll({
|
currentDeclarationSuite.beforeAll({
|
||||||
fn: beforeAllFunction,
|
fn: beforeAllFunction,
|
||||||
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
|
timeout: timeout || 0
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -784,7 +784,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
afterEachFunction.isCleanup = true;
|
afterEachFunction.isCleanup = true;
|
||||||
currentDeclarationSuite.afterEach({
|
currentDeclarationSuite.afterEach({
|
||||||
fn: afterEachFunction,
|
fn: afterEachFunction,
|
||||||
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
|
timeout: timeout || 0
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -793,7 +793,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
ensureIsFunctionOrAsync(afterAllFunction, 'afterAll');
|
ensureIsFunctionOrAsync(afterAllFunction, 'afterAll');
|
||||||
currentDeclarationSuite.afterAll({
|
currentDeclarationSuite.afterAll({
|
||||||
fn: afterAllFunction,
|
fn: afterAllFunction,
|
||||||
timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; }
|
timeout: timeout || 0
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -105,12 +105,16 @@ getJasmineRequireObj().QueueRunner = function(j$) {
|
|||||||
|
|
||||||
self.globalErrors.pushListener(handleError);
|
self.globalErrors.pushListener(handleError);
|
||||||
|
|
||||||
if (queueableFn.timeout) {
|
if (queueableFn.timeout !== undefined) {
|
||||||
|
var timeoutInterval = queueableFn.timeout || j$.DEFAULT_TIMEOUT_INTERVAL;
|
||||||
timeoutId = self.setTimeout(function() {
|
timeoutId = self.setTimeout(function() {
|
||||||
var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.');
|
var error = new Error(
|
||||||
|
'Timeout - Async callback was not invoked within ' + timeoutInterval + 'ms ' +
|
||||||
|
(queueableFn.timeout ? '(custom timeout)' : '(set by jasmine.DEFAULT_TIMEOUT_INTERVAL)')
|
||||||
|
);
|
||||||
onException(error);
|
onException(error);
|
||||||
next();
|
next();
|
||||||
}, queueableFn.timeout());
|
}, timeoutInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user