Commit 79de7066 authored by Paul Slaughter's avatar Paul Slaughter

Setup integration test setup

- Also moves special snapshot serializer to its
  own module.
parent ef2177f6
import '../../../frontend/test_setup';
import './setup_globals';
import './setup_axios';
import './setup_serializers';
import axios from '~/lib/utils/axios_utils';
import adapter from 'axios/lib/adapters/xhr';
// We're removing our default axios adapter because this is handled by our mock server now
axios.defaults.adapter = adapter;
import { setTestTimeout } from 'helpers/timeout';
beforeEach(() => {
window.gon = {
api_version: 'v4',
relative_url_root: '',
};
setTestTimeout(5000);
jest.useRealTimers();
});
afterEach(() => {
jest.useFakeTimers();
});
import defaultSerializer from '../snapshot_serializer';
expect.addSnapshotSerializer(defaultSerializer);
export default {
test(value) {
return value instanceof HTMLElement && !value.$_hit;
},
print(element, serialize) {
element.$_hit = true;
element.querySelectorAll('[style]').forEach(el => {
el.$_hit = true;
if (el.style.display === 'none') {
el.textContent = '(jest: contents hidden)';
}
});
return serialize(element)
.replace(/^\s*<!---->$/gm, '')
.replace(/\n\s*\n/gm, '\n');
},
};
import './test_helpers/setup';
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment