Increase Jest timeout on CI to 5 seconds

This commit is contained in:
Winnie Hellmann 2019-06-06 16:52:20 +00:00 committed by Phil Hughes
parent 70a717daf9
commit 7100c6b581
2 changed files with 15 additions and 3 deletions

View File

@ -5,7 +5,13 @@ const IS_DEBUGGING = process.execArgv.join(' ').includes('--inspect-brk');
let testTimeoutNS; let testTimeoutNS;
export const setTestTimeout = newTimeoutMS => { export const setTestTimeout = newTimeoutMS => {
testTimeoutNS = newTimeoutMS * NS_PER_MS; const newTimeoutNS = newTimeoutMS * NS_PER_MS;
// never accept a smaller timeout than the default
if (newTimeoutNS < testTimeoutNS) {
return;
}
testTimeoutNS = newTimeoutNS;
jest.setTimeout(newTimeoutMS); jest.setTimeout(newTimeoutMS);
}; };
@ -13,7 +19,13 @@ export const setTestTimeout = newTimeoutMS => {
// Useful for tests with jQuery, which is very slow in big DOMs. // Useful for tests with jQuery, which is very slow in big DOMs.
let temporaryTimeoutNS = null; let temporaryTimeoutNS = null;
export const setTestTimeoutOnce = newTimeoutMS => { export const setTestTimeoutOnce = newTimeoutMS => {
temporaryTimeoutNS = newTimeoutMS * NS_PER_MS; const newTimeoutNS = newTimeoutMS * NS_PER_MS;
// never accept a smaller timeout than the default
if (newTimeoutNS < testTimeoutNS) {
return;
}
temporaryTimeoutNS = newTimeoutNS;
}; };
export const initializeTestTimeout = defaultTimeoutMS => { export const initializeTestTimeout = defaultTimeoutMS => {

View File

@ -15,7 +15,7 @@ afterEach(() =>
}), }),
); );
initializeTestTimeout(500); initializeTestTimeout(process.env.CI ? 5000 : 500);
// fail tests for unmocked requests // fail tests for unmocked requests
beforeEach(done => { beforeEach(done => {