gitlab-org--gitlab-foss/spec/frontend/test_setup.js

35 lines
921 B
JavaScript
Raw Normal View History

2019-02-20 15:26:44 -05:00
import Vue from 'vue';
import Translate from '~/vue_shared/translate';
2019-02-20 14:59:44 -05:00
import axios from '~/lib/utils/axios_utils';
import { initializeTestTimeout } from './helpers/timeout';
2019-02-20 14:59:44 -05:00
2019-03-21 13:05:21 -04:00
// wait for pending setTimeout()s
afterEach(() => {
jest.runAllTimers();
});
initializeTestTimeout(300);
2019-02-20 14:59:44 -05:00
// 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();
});
2019-02-20 15:26:44 -05:00
Vue.use(Translate);
2019-03-28 15:42:32 -04:00
// workaround for JSDOM not supporting innerText
// see https://github.com/jsdom/jsdom/issues/1245
Object.defineProperty(global.Element.prototype, 'innerText', {
get() {
return this.textContent;
},
configurable: true, // make it so that it doesn't blow chunks on re-running tests with things like --watch
});