summaryrefslogtreecommitdiff
path: root/spec/frontend
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2018-09-06 19:36:04 +0200
committerWinnie Hellmann <winnie@gitlab.com>2018-12-11 13:06:19 +0100
commitfac4d54f3d4a7ce2e992c490c9a1164ae4ff17ac (patch)
tree3c1b3d7d4541af2cdd28f0564827fa72e833af12 /spec/frontend
parentca3603de56445862b47cbc9b8eec50cbf82d71c3 (diff)
downloadgitlab-ce-fac4d54f3d4a7ce2e992c490c9a1164ae4ff17ac.tar.gz
Fail long running tests
Diffstat (limited to 'spec/frontend')
-rw-r--r--spec/frontend/test_setup.js16
1 files changed, 16 insertions, 0 deletions
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)!`);
+ }
+});