diff options
author | Martin Hanzel <mhanzel@gitlab.com> | 2019-07-17 20:47:39 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2019-07-17 20:47:39 +0300 |
commit | eb45cb8c99f4232da90c26b307eff35c926d1975 (patch) | |
tree | a1e14c5f34baae8257b4774b6d2b610b8e08284f /spec/frontend/test_setup.js | |
parent | 48195a517183560cdc673273440c7d757cf40821 (diff) |
Mockify jquery and axios packages
Moved the block that fails tests on unmocked axios requests from
test_setup to its own mock, and added a jQuery mock that fails
tests if they use unmocked $.ajax().
Diffstat (limited to 'spec/frontend/test_setup.js')
-rw-r--r-- | spec/frontend/test_setup.js | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/spec/frontend/test_setup.js b/spec/frontend/test_setup.js index 15cf18700ed..634c78ec029 100644 --- a/spec/frontend/test_setup.js +++ b/spec/frontend/test_setup.js @@ -2,10 +2,10 @@ import Vue from 'vue'; import * as jqueryMatchers from 'custom-jquery-matchers'; import $ from 'jquery'; import Translate from '~/vue_shared/translate'; -import axios from '~/lib/utils/axios_utils'; import { config as testUtilsConfig } from '@vue/test-utils'; import { initializeTestTimeout } from './helpers/timeout'; import { loadHTMLFixture, setHTMLFixture } from './helpers/fixtures'; +import { setupManualMocks } from './mocks/mocks_helper'; // Expose jQuery so specs using jQuery plugins can be imported nicely. // Here is an issue to explore better alternatives: @@ -14,6 +14,8 @@ window.jQuery = $; process.on('unhandledRejection', global.promiseRejectionHandler); +setupManualMocks(); + afterEach(() => // give Promises a bit more time so they fail the right test new Promise(setImmediate).then(() => { @@ -24,18 +26,6 @@ afterEach(() => initializeTestTimeout(process.env.CI ? 5000 : 500); -// 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(); -}); - Vue.config.devtools = false; Vue.config.productionTip = false; |