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(); +});