Commit 6d6b9470 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch 'fix-flaky-spec' into 'master'

Fixes flaky spec in`spec/frontend/ide/components/merge_requests/list_spec.js`

See merge request gitlab-org/gitlab!28807
parents c9ab7ad5 755fc84b
......@@ -35,7 +35,6 @@ const MERGE_REQUEST_CLOSED = 'merge_request_closed';
let store = null;
const localVue = createLocalVue();
localVue.use(Vuex);
jest.mock('lodash/debounce', () => jest.fn);
describe('CustomStageForm', () => {
function createComponent(props = {}, stubs = {}) {
......
......@@ -20,8 +20,6 @@ const findFlashError = () => document.querySelector('.flash-container .flash-tex
const mockGroupLabelsRequest = (status = 200) =>
new MockAdapter(axios).onGet().reply(status, groupLabels);
jest.mock('lodash/debounce', () => jest.fn);
describe('Value Stream Analytics LabelsSelector', () => {
let store = null;
const localVue = createLocalVue();
......
......@@ -32,7 +32,6 @@ const selectLabelAtIndex = (ctx, index) => {
const mockGroupLabelsRequest = () => new MockAdapter(axios).onGet().reply(200, groupLabels);
jest.mock('lodash/debounce', () => jest.fn);
let store = null;
const localVue = createLocalVue();
localVue.use(Vuex);
......
......@@ -4,8 +4,6 @@ import RuleInput from 'ee/approvals/components/mr_edit/rule_input.vue';
import MREditModule from 'ee/approvals/stores/modules/mr_edit';
import { createStoreOptions } from 'ee/approvals/stores';
jest.mock('lodash/debounce', () => jest.fn(fn => fn));
const localVue = createLocalVue();
localVue.use(Vuex);
......
......@@ -6,7 +6,6 @@ import { createStore } from '~/ide/stores';
import eventHub from '~/ide/eventhub';
jest.mock('ee/ide/lib/mirror');
jest.mock('lodash/debounce', () => jest.fn);
const ACTION_START = 'terminalSync/start';
const ACTION_STOP = 'terminalSync/stop';
......
......@@ -4,8 +4,6 @@ import { GlDeprecatedButton } from '@gitlab/ui';
import DropdownSearchInput from 'ee/vue_shared/components/sidebar/epics_select/dropdown_search_input.vue';
import Icon from '~/vue_shared/components/icon.vue';
jest.mock('lodash/debounce', () => jest.fn(fn => fn));
const createComponent = () =>
shallowMount(DropdownSearchInput, {
directives: {
......
// `lodash/debounce` has a non-trivial implementation which can lead to
// [flaky spec errors][1]. This mock simply makes `debounce` calls synchronous.
//
// In the future we could enhance this by injecting some test values in
// the function passed to it. See [this issue][2] for more information.
//
// [1]: https://gitlab.com/gitlab-org/gitlab/-/issues/212532
// [2]: https://gitlab.com/gitlab-org/gitlab/-/issues/213378
// Further reference: https://github.com/facebook/jest/issues/3465
export default fn => fn;
......@@ -9,8 +9,6 @@ import { branches } from '../../mock_data';
const localVue = createLocalVue();
localVue.use(Vuex);
jest.mock('lodash/debounce', () => jest.fn);
describe('IDE branches search list', () => {
let wrapper;
const fetchBranchesMock = jest.fn();
......
......@@ -134,9 +134,7 @@ describe('IDE merge requests list', () => {
createComponent(defaultStateWithMergeRequests);
const input = findTokenedInput();
input.vm.$emit('input', 'something');
fetchMergeRequestsMock.mockClear();
jest.runAllTimers();
return wrapper.vm.$nextTick().then(() => {
expect(fetchMergeRequestsMock).toHaveBeenCalledWith(
expect.any(Object),
......
......@@ -20,7 +20,7 @@ afterEach(() =>
// give Promises a bit more time so they fail the right test
new Promise(setImmediate).then(() => {
// wait for pending setTimeout()s
jest.runAllTimers();
jest.runOnlyPendingTimers();
}),
);
......
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