gitlab-org--gitlab-foss/spec/frontend/test_setup.js
2018-12-11 13:06:19 +01:00

16 lines
399 B
JavaScript

const testTimeoutInMs = 300;
jest.setTimeout(testTimeoutInMs);
let testStartTime;
// https://github.com/facebook/jest/issues/6947
beforeEach(() => {
testStartTime = Date.now();
});
afterEach(() => {
const elapsedTimeInMs = Date.now() - testStartTime;
if (elapsedTimeInMs > testTimeoutInMs) {
throw new Error(`Test took too long (${elapsedTimeInMs}ms > ${testTimeoutInMs}ms)!`);
}
});