Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2018-09-06 20:36:04 +0300
committerWinnie Hellmann <winnie@gitlab.com>2018-12-11 15:06:19 +0300
commitfac4d54f3d4a7ce2e992c490c9a1164ae4ff17ac (patch)
tree3c1b3d7d4541af2cdd28f0564827fa72e833af12
parentca3603de56445862b47cbc9b8eec50cbf82d71c3 (diff)
Fail long running tests
-rw-r--r--jest.config.js1
-rw-r--r--spec/frontend/test_setup.js16
2 files changed, 17 insertions, 0 deletions
diff --git a/jest.config.js b/jest.config.js
index 0a7b2aedb42..8e4f207af64 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -24,4 +24,5 @@ module.exports = {
cacheDirectory: '<rootDir>/tmp/cache/jest',
modulePathIgnorePatterns: ['<rootDir>/.yarn-cache/'],
reporters,
+ setupTestFrameworkScriptFile: '<rootDir>/spec/frontend/test_setup.js',
};
diff --git a/spec/frontend/test_setup.js b/spec/frontend/test_setup.js
new file mode 100644
index 00000000000..742ea60ecbd
--- /dev/null
+++ b/spec/frontend/test_setup.js
@@ -0,0 +1,16 @@
+const testTimeoutInMs = 0;
+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)!`);
+ }
+});