diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2018-04-23 19:18:30 +0200 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2018-07-23 13:44:06 +0200 |
commit | f6e28443a526f6b24c17d34ed302267897e04650 (patch) | |
tree | 67f624c5324846c797fb74b0fc75d46c6c5beb3e /spec/javascripts/test_bundle.js | |
parent | f6d13ef53aa50541ec0c751156424d7c49bf3322 (diff) | |
download | gitlab-ce-f6e28443a526f6b24c17d34ed302267897e04650.tar.gz |
Fail tests if Axios is not mockedwinh-mock-axios-requests
Diffstat (limited to 'spec/javascripts/test_bundle.js')
-rw-r--r-- | spec/javascripts/test_bundle.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/spec/javascripts/test_bundle.js b/spec/javascripts/test_bundle.js index bc00fdfd73c..33b3ee430b2 100644 --- a/spec/javascripts/test_bundle.js +++ b/spec/javascripts/test_bundle.js @@ -8,7 +8,7 @@ import VueResource from 'vue-resource'; import Translate from '~/vue_shared/translate'; import jasmineDiff from 'jasmine-diff'; -import { getDefaultAdapter } from '~/lib/utils/axios_utils'; +import axios from '~/lib/utils/axios_utils'; import { FIXTURES_PATH, TEST_HOST } from './test_constants'; import customMatchers from './matchers'; @@ -91,7 +91,10 @@ beforeEach(() => { Vue.http.interceptors = builtinVueHttpInterceptors.slice(); }); -const axiosDefaultAdapter = getDefaultAdapter(); +// see https://github.com/axios/axios/tree/master/lib/adapters +const axiosDummyAdapter = () => fail('Axios request not mocked!'); +axiosDummyAdapter.isNotMocked = true; +axios.defaults.adapter = axiosDummyAdapter; // render all of our tests const testsContext = require.context('.', true, /_spec$/); @@ -131,7 +134,7 @@ describe('test errors', () => { }); it('restores axios adapter after mocking', () => { - if (getDefaultAdapter() !== axiosDefaultAdapter) { + if (axios.defaults.adapter !== axiosDummyAdapter) { fail('axios adapter is not restored! Did you forget a restore() on MockAdapter?'); } }); |