summaryrefslogtreecommitdiff
path: root/spec/frontend/test_setup.js
diff options
context:
space:
mode:
authorWinnie Hellmann <winnie@gitlab.com>2019-02-20 20:59:44 +0100
committerWinnie Hellmann <winnie@gitlab.com>2019-02-21 09:39:59 +0100
commit13bb3483d8eb1d0bb30f4ec8d433c52f3675b0f1 (patch)
tree8efa0bb9a823770ae5c05a179364582f0c7952e9 /spec/frontend/test_setup.js
parent69f9ec77c208db4f07d0c5f7b1c7b59460d6cec7 (diff)
downloadgitlab-ce-13bb3483d8eb1d0bb30f4ec8d433c52f3675b0f1.tar.gz
Fail tests for unmocked axios requests
Diffstat (limited to 'spec/frontend/test_setup.js')
-rw-r--r--spec/frontend/test_setup.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/frontend/test_setup.js b/spec/frontend/test_setup.js
index 7ad2e97e7e6..4e4dd72a799 100644
--- a/spec/frontend/test_setup.js
+++ b/spec/frontend/test_setup.js
@@ -1,3 +1,5 @@
+import axios from '~/lib/utils/axios_utils';
+
const testTimeoutInMs = 300;
jest.setTimeout(testTimeoutInMs);
@@ -14,3 +16,15 @@ afterEach(() => {
throw new Error(`Test took too long (${elapsedTimeInMs}ms > ${testTimeoutInMs}ms)!`);
}
});
+
+// fail tests for unmocked requests
+beforeEach(done => {
+ axios.defaults.adapter = config => {
+ const error = new Error(`Unexpected unmocked request: ${JSON.stringify(config, null, 2)}`);
+ error.config = config;
+ done.fail(error);
+ return Promise.reject(error);
+ };
+
+ done();
+});