Commit adebc389 authored by Simon Knox's avatar Simon Knox

Merge branch 'peterhegman/remove-toExist-jest-matcher' into 'master'

Remove `toExist` jest matcher

See merge request gitlab-org/gitlab!73874
parents 303fb2c7 cf260ffe
...@@ -213,6 +213,7 @@ export default { ...@@ -213,6 +213,7 @@ export default {
<div <div
v-if="hasRotateError" v-if="hasRotateError"
class="gl-text-red-500 gl-display-flex gl-align-items-center gl-font-weight-normal gl-mb-3" class="gl-text-red-500 gl-display-flex gl-align-items-center gl-font-weight-normal gl-mb-3"
data-testid="rotate-error"
> >
<gl-icon name="warning" class="gl-mr-2" /> <gl-icon name="warning" class="gl-mr-2" />
<span>{{ $options.translations.instanceIdRegenerateError }}</span> <span>{{ $options.translations.instanceIdRegenerateError }}</span>
......
...@@ -82,7 +82,11 @@ export default { ...@@ -82,7 +82,11 @@ export default {
<slot v-if="showRightSlot" name="right-content"></slot> <slot v-if="showRightSlot" name="right-content"></slot>
<div v-else-if="showActionButtons" class="gl-flex-shrink-0 gl-align-self-start"> <div
v-else-if="showActionButtons"
class="gl-flex-shrink-0 gl-align-self-start"
data-testid="action-buttons"
>
<gl-button <gl-button
v-for="button in actionButtons" v-for="button in actionButtons"
:key="button.title" :key="button.title"
......
...@@ -55,12 +55,12 @@ describe('SharedForm', () => { ...@@ -55,12 +55,12 @@ describe('SharedForm', () => {
it('shows the correct input and button fields', () => { it('shows the correct input and button fields', () => {
wrapper = createComponent(); wrapper = createComponent();
expect(findNameInput()).toExist(); expect(findNameInput().exists()).toBe(true);
expect(findDescriptionInput()).toExist(); expect(findDescriptionInput().exists()).toBe(true);
expect(findPipelineConfigurationInput()).toExist(); expect(findPipelineConfigurationInput().exists()).toBe(true);
expect(findColorPicker()).toExist(); expect(findColorPicker().exists()).toBe(true);
expect(findSubmitBtn()).toExist(); expect(findSubmitBtn().exists()).toBe(true);
expect(findCancelBtn()).toExist(); expect(findCancelBtn().exists()).toBe(true);
}); });
it('sets the submit button text from the property', () => { it('sets the submit button text from the property', () => {
......
...@@ -23,12 +23,6 @@ describe('EpicHealthStatus', () => { ...@@ -23,12 +23,6 @@ describe('EpicHealthStatus', () => {
wrapper.destroy(); wrapper.destroy();
}); });
it('renders tooltip', () => {
const tooltip = wrapper.find(GlTooltip);
expect(tooltip).toExist();
});
describe('when no statuses are assigned', () => { describe('when no statuses are assigned', () => {
it('hasHealthStatus computed property returns false', () => { it('hasHealthStatus computed property returns false', () => {
expect(wrapper.vm.hasHealthStatus).toBe(false); expect(wrapper.vm.hasHealthStatus).toBe(false);
...@@ -54,6 +48,12 @@ describe('EpicHealthStatus', () => { ...@@ -54,6 +48,12 @@ describe('EpicHealthStatus', () => {
}); });
}); });
it('renders tooltip', () => {
const tooltip = wrapper.find(GlTooltip);
expect(tooltip.exists()).toBe(true);
});
it('hasHealthStatus computed property returns false', () => { it('hasHealthStatus computed property returns false', () => {
expect(wrapper.vm.hasHealthStatus).toBe(true); expect(wrapper.vm.hasHealthStatus).toBe(true);
}); });
......
...@@ -37,7 +37,7 @@ describe('IssueHealthStatus', () => { ...@@ -37,7 +37,7 @@ describe('IssueHealthStatus', () => {
it('applies correct health status class', () => { it('applies correct health status class', () => {
const expectedValue = issueHealthStatusCSSMapping[healthStatus]; const expectedValue = issueHealthStatusCSSMapping[healthStatus];
expect(wrapper.find(`.${expectedValue}`)).toExist(); expect(wrapper.find(`.${expectedValue}`).exists()).toBe(true);
}); });
it('contains health status tooltip', () => { it('contains health status tooltip', () => {
......
...@@ -66,7 +66,6 @@ describe('ImportRequirementsModal', () => { ...@@ -66,7 +66,6 @@ describe('ImportRequirementsModal', () => {
const emitted = wrapper.emitted('import')[0][0]; const emitted = wrapper.emitted('import')[0][0];
expect(emitted).toExist();
expect(emitted.file).toBe(file); expect(emitted.file).toBe(file);
expect(emitted.projectPath).toBe(wrapper.vm.projectPath); expect(emitted.projectPath).toBe(wrapper.vm.projectPath);
}); });
......
...@@ -48,7 +48,7 @@ describe('EE - DastSavedScansList', () => { ...@@ -48,7 +48,7 @@ describe('EE - DastSavedScansList', () => {
}; };
const createFullComponent = wrapperFactory(mount); const createFullComponent = wrapperFactory(mount);
const findProfileList = () => wrapper.find(ProfilesList); const findProfileList = () => wrapper.findComponent(ProfilesList);
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
...@@ -59,7 +59,7 @@ describe('EE - DastSavedScansList', () => { ...@@ -59,7 +59,7 @@ describe('EE - DastSavedScansList', () => {
propsData: { profiles: savedScans }, propsData: { profiles: savedScans },
}); });
expect(findProfileList()).toExist(); expect(findProfileList().exists()).toBe(true);
}); });
it('renders branch information for each profile', () => { it('renders branch information for each profile', () => {
......
...@@ -33,7 +33,7 @@ describe('EE - DastScannerProfileList', () => { ...@@ -33,7 +33,7 @@ describe('EE - DastScannerProfileList', () => {
}; };
const createFullComponent = wrapperFactory(mount); const createFullComponent = wrapperFactory(mount);
const findProfileList = () => wrapper.find(ProfilesList); const findProfileList = () => wrapper.findComponent(ProfilesList);
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
...@@ -44,7 +44,7 @@ describe('EE - DastScannerProfileList', () => { ...@@ -44,7 +44,7 @@ describe('EE - DastScannerProfileList', () => {
propsData: { profiles: scannerProfiles }, propsData: { profiles: scannerProfiles },
}); });
expect(findProfileList()).toExist(); expect(findProfileList().exists()).toBe(true);
}); });
it('passes down the props properly', () => { it('passes down the props properly', () => {
......
...@@ -71,7 +71,7 @@ describe('EE - DastSiteProfileList', () => { ...@@ -71,7 +71,7 @@ describe('EE - DastSiteProfileList', () => {
const getAllTableRows = () => within(getTableBody()).getAllByRole('row'); const getAllTableRows = () => within(getTableBody()).getAllByRole('row');
const getTableRowForProfile = (profile) => getAllTableRows()[siteProfiles.indexOf(profile)]; const getTableRowForProfile = (profile) => getAllTableRows()[siteProfiles.indexOf(profile)];
const findProfileList = () => wrapper.find(ProfilesList); const findProfileList = () => wrapper.findComponent(ProfilesList);
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
...@@ -83,7 +83,7 @@ describe('EE - DastSiteProfileList', () => { ...@@ -83,7 +83,7 @@ describe('EE - DastSiteProfileList', () => {
propsData: { profiles: siteProfiles }, propsData: { profiles: siteProfiles },
}); });
expect(findProfileList()).toExist(); expect(findProfileList().exists()).toBe(true);
}); });
it('passes down the props properly', () => { it('passes down the props properly', () => {
...@@ -155,7 +155,7 @@ describe('EE - DastSiteProfileList', () => { ...@@ -155,7 +155,7 @@ describe('EE - DastSiteProfileList', () => {
const validateButton = within(actionsCell).queryByRole('button', { const validateButton = within(actionsCell).queryByRole('button', {
name: buttonLabel, name: buttonLabel,
}); });
expect(validateButton).toExist(); expect(validateButton).not.toBe(null);
}); });
it(`should ${isBtnDisabled ? '' : 'not '}disable ${buttonLabel} button`, () => { it(`should ${isBtnDisabled ? '' : 'not '}disable ${buttonLabel} button`, () => {
......
...@@ -165,7 +165,7 @@ describe('Storage counter app', () => { ...@@ -165,7 +165,7 @@ describe('Storage counter app', () => {
it('does render link', () => { it('does render link', () => {
const link = findPurchaseStorageLink(); const link = findPurchaseStorageLink();
expect(link).toExist(); expect(link.exists()).toBe(true);
expect(link.attributes('href')).toBe('customers.gitlab.com'); expect(link.attributes('href')).toBe('customers.gitlab.com');
}); });
}); });
......
...@@ -83,6 +83,7 @@ exports[`Event Item with action buttons renders the action buttons 1`] = ` ...@@ -83,6 +83,7 @@ exports[`Event Item with action buttons renders the action buttons 1`] = `
<div <div
class="gl-flex-shrink-0 gl-align-self-start" class="gl-flex-shrink-0 gl-align-self-start"
data-testid="action-buttons"
> >
<button <button
aria-label="Foo Action" aria-label="Foo Action"
......
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import { shallowMount, mount } from '@vue/test-utils';
import { shallowMountExtended, mountExtended } from 'helpers/vue_test_utils_helper';
import Component from 'ee/vue_shared/security_reports/components/event_item.vue'; import Component from 'ee/vue_shared/security_reports/components/event_item.vue';
import NoteHeader from '~/notes/components/note_header.vue'; import NoteHeader from '~/notes/components/note_header.vue';
describe('Event Item', () => { describe('Event Item', () => {
let wrapper; let wrapper;
const mountComponent = (options, mountFn = shallowMount) => { const mountComponent = (options, mountFn = shallowMountExtended) => {
wrapper = mountFn(Component, options); wrapper = mountFn(Component, options);
}; };
...@@ -51,7 +52,7 @@ describe('Event Item', () => { ...@@ -51,7 +52,7 @@ describe('Event Item', () => {
}); });
it('renders the action buttons container', () => { it('renders the action buttons container', () => {
expect(wrapper.find('.action-buttons')).toExist(); expect(wrapper.findByTestId('action-buttons').exists()).toBe(true);
}); });
it('renders the default slot', () => { it('renders the default slot', () => {
...@@ -83,11 +84,11 @@ describe('Event Item', () => { ...@@ -83,11 +84,11 @@ describe('Event Item', () => {
}); });
beforeEach(() => { beforeEach(() => {
mountComponent({ propsData }, mount); mountComponent({ propsData }, mountExtended);
}); });
it('renders the action buttons container', () => { it('renders the action buttons container', () => {
expect(wrapper.find('.action-buttons')).toExist(); expect(wrapper.findByTestId('action-buttons').exists()).toBe(true);
}); });
it('renders the action buttons', () => { it('renders the action buttons', () => {
......
...@@ -26,12 +26,12 @@ describe('Alert Handler', () => { ...@@ -26,12 +26,12 @@ describe('Alert Handler', () => {
}); });
it('should render the alert', () => { it('should render the alert', () => {
expect(findFirstAlert()).toExist(); expect(findFirstAlert()).not.toBe(null);
}); });
it('should dismiss the alert on click', () => { it('should dismiss the alert on click', () => {
findFirstDismissButton().click(); findFirstDismissButton().click();
expect(findFirstAlert()).not.toExist(); expect(findFirstAlert()).toBe(null);
}); });
}); });
...@@ -58,12 +58,12 @@ describe('Alert Handler', () => { ...@@ -58,12 +58,12 @@ describe('Alert Handler', () => {
}); });
it('should render the banner', () => { it('should render the banner', () => {
expect(findFirstBanner()).toExist(); expect(findFirstBanner()).not.toBe(null);
}); });
it('should dismiss the banner on click', () => { it('should dismiss the banner on click', () => {
findFirstDismissButton().click(); findFirstDismissButton().click();
expect(findFirstBanner()).not.toExist(); expect(findFirstBanner()).toBe(null);
}); });
}); });
...@@ -79,12 +79,12 @@ describe('Alert Handler', () => { ...@@ -79,12 +79,12 @@ describe('Alert Handler', () => {
}); });
it('should render the banner', () => { it('should render the banner', () => {
expect(findFirstAlert()).toExist(); expect(findFirstAlert()).not.toBe(null);
}); });
it('should dismiss the banner on click', () => { it('should dismiss the banner on click', () => {
findFirstDismissButtonByClass().click(); findFirstDismissButtonByClass().click();
expect(findFirstAlert()).not.toExist(); expect(findFirstAlert()).toBe(null);
}); });
}); });
}); });
......
...@@ -72,7 +72,7 @@ describe('ConfirmModal', () => { ...@@ -72,7 +72,7 @@ describe('ConfirmModal', () => {
it('starts with only JsHooks', () => { it('starts with only JsHooks', () => {
expect(findJsHooks()).toHaveLength(buttons.length); expect(findJsHooks()).toHaveLength(buttons.length);
expect(findModal()).not.toExist(); expect(findModal()).toBe(null);
}); });
describe('when button clicked', () => { describe('when button clicked', () => {
...@@ -87,7 +87,7 @@ describe('ConfirmModal', () => { ...@@ -87,7 +87,7 @@ describe('ConfirmModal', () => {
describe('GlModal', () => { describe('GlModal', () => {
it('is rendered', () => { it('is rendered', () => {
expect(findModal()).toExist(); expect(findModal()).not.toBe(null);
expect(modalIsHidden()).toBe(false); expect(modalIsHidden()).toBe(false);
}); });
......
...@@ -40,7 +40,7 @@ describe('DeleteLabelModal', () => { ...@@ -40,7 +40,7 @@ describe('DeleteLabelModal', () => {
it('starts with only js-containers', () => { it('starts with only js-containers', () => {
expect(findJsHooks()).toHaveLength(buttons.length); expect(findJsHooks()).toHaveLength(buttons.length);
expect(findModal()).not.toExist(); expect(findModal()).toBe(null);
}); });
describe('when first button clicked', () => { describe('when first button clicked', () => {
...@@ -54,7 +54,7 @@ describe('DeleteLabelModal', () => { ...@@ -54,7 +54,7 @@ describe('DeleteLabelModal', () => {
}); });
it('renders GlModal', () => { it('renders GlModal', () => {
expect(findModal()).toExist(); expect(findModal()).not.toBe(null);
}); });
}); });
......
...@@ -50,20 +50,20 @@ describe('Deploy keys key', () => { ...@@ -50,20 +50,20 @@ describe('Deploy keys key', () => {
it('shows pencil button for editing', () => { it('shows pencil button for editing', () => {
createComponent({ deployKey }); createComponent({ deployKey });
expect(wrapper.find('.btn [data-testid="pencil-icon"]')).toExist(); expect(wrapper.find('.btn [data-testid="pencil-icon"]').exists()).toBe(true);
}); });
it('shows disable button when the project is not deletable', () => { it('shows disable button when the project is not deletable', () => {
createComponent({ deployKey }); createComponent({ deployKey });
expect(wrapper.find('.btn [data-testid="cancel-icon"]')).toExist(); expect(wrapper.find('.btn [data-testid="cancel-icon"]').exists()).toBe(true);
}); });
it('shows remove button when the project is deletable', () => { it('shows remove button when the project is deletable', () => {
createComponent({ createComponent({
deployKey: { ...deployKey, destroyed_when_orphaned: true, almost_orphaned: true }, deployKey: { ...deployKey, destroyed_when_orphaned: true, almost_orphaned: true },
}); });
expect(wrapper.find('.btn [data-testid="remove-icon"]')).toExist(); expect(wrapper.find('.btn [data-testid="remove-icon"]').exists()).toBe(true);
}); });
}); });
...@@ -137,7 +137,7 @@ describe('Deploy keys key', () => { ...@@ -137,7 +137,7 @@ describe('Deploy keys key', () => {
it('shows pencil button for editing', () => { it('shows pencil button for editing', () => {
createComponent({ deployKey }); createComponent({ deployKey });
expect(wrapper.find('.btn [data-testid="pencil-icon"]')).toExist(); expect(wrapper.find('.btn [data-testid="pencil-icon"]').exists()).toBe(true);
}); });
it('shows disable button when key is enabled', () => { it('shows disable button when key is enabled', () => {
...@@ -145,7 +145,7 @@ describe('Deploy keys key', () => { ...@@ -145,7 +145,7 @@ describe('Deploy keys key', () => {
createComponent({ deployKey }); createComponent({ deployKey });
expect(wrapper.find('.btn [data-testid="cancel-icon"]')).toExist(); expect(wrapper.find('.btn [data-testid="cancel-icon"]').exists()).toBe(true);
}); });
}); });
}); });
...@@ -37,7 +37,7 @@ describe('Deploy keys panel', () => { ...@@ -37,7 +37,7 @@ describe('Deploy keys panel', () => {
mountComponent(); mountComponent();
const tableHeader = findTableRowHeader(); const tableHeader = findTableRowHeader();
expect(tableHeader).toExist(); expect(tableHeader.exists()).toBe(true);
expect(tableHeader.text()).toContain('Deploy key'); expect(tableHeader.text()).toContain('Deploy key');
expect(tableHeader.text()).toContain('Project usage'); expect(tableHeader.text()).toContain('Project usage');
expect(tableHeader.text()).toContain('Created'); expect(tableHeader.text()).toContain('Created');
......
...@@ -87,7 +87,7 @@ describe('Design management list item component', () => { ...@@ -87,7 +87,7 @@ describe('Design management list item component', () => {
describe('before image is loaded', () => { describe('before image is loaded', () => {
it('renders loading spinner', () => { it('renders loading spinner', () => {
expect(wrapper.find(GlLoadingIcon)).toExist(); expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
}); });
}); });
......
import { GlModal, GlSprintf, GlAlert } from '@gitlab/ui'; import { GlModal, GlSprintf, GlAlert } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import Component from '~/feature_flags/components/configure_feature_flags_modal.vue'; import Component from '~/feature_flags/components/configure_feature_flags_modal.vue';
describe('Configure Feature Flags Modal', () => { describe('Configure Feature Flags Modal', () => {
...@@ -20,7 +21,7 @@ describe('Configure Feature Flags Modal', () => { ...@@ -20,7 +21,7 @@ describe('Configure Feature Flags Modal', () => {
}; };
let wrapper; let wrapper;
const factory = (props = {}, { mountFn = shallowMount, ...options } = {}) => { const factory = (props = {}, { mountFn = shallowMountExtended, ...options } = {}) => {
wrapper = mountFn(Component, { wrapper = mountFn(Component, {
provide, provide,
stubs: { GlSprintf }, stubs: { GlSprintf },
...@@ -140,11 +141,13 @@ describe('Configure Feature Flags Modal', () => { ...@@ -140,11 +141,13 @@ describe('Configure Feature Flags Modal', () => {
describe('has rotate error', () => { describe('has rotate error', () => {
afterEach(() => wrapper.destroy()); afterEach(() => wrapper.destroy());
beforeEach(factory.bind(null, { hasRotateError: false })); beforeEach(() => {
factory({ hasRotateError: true });
});
it('should display an error', async () => { it('should display an error', async () => {
expect(wrapper.find('.text-danger')).toExist(); expect(wrapper.findByTestId('rotate-error').exists()).toBe(true);
expect(wrapper.find('[name="warning"]')).toExist(); expect(wrapper.find('[name="warning"]').exists()).toBe(true);
}); });
}); });
......
...@@ -198,7 +198,7 @@ describe('InviteMembersModal', () => { ...@@ -198,7 +198,7 @@ describe('InviteMembersModal', () => {
describe('rendering the access expiration date field', () => { describe('rendering the access expiration date field', () => {
it('renders the datepicker', () => { it('renders the datepicker', () => {
expect(findDatepicker()).toExist(); expect(findDatepicker().exists()).toBe(true);
}); });
}); });
}); });
......
import { GlButton, GlModal } from '@gitlab/ui'; import { GlModal } from '@gitlab/ui';
import { stubComponent } from 'helpers/stub_component'; import { stubComponent } from 'helpers/stub_component';
import { mountExtended } from 'helpers/vue_test_utils_helper'; import { mountExtended } from 'helpers/vue_test_utils_helper';
import CsvImportModal from '~/issuable/components/csv_import_modal.vue'; import CsvImportModal from '~/issuable/components/csv_import_modal.vue';
import { __ } from '~/locale';
jest.mock('~/lib/utils/csrf', () => ({ token: 'mock-csrf-token' })); jest.mock('~/lib/utils/csrf', () => ({ token: 'mock-csrf-token' }));
...@@ -36,7 +37,6 @@ describe('CsvImportModal', () => { ...@@ -36,7 +37,6 @@ describe('CsvImportModal', () => {
}); });
const findModal = () => wrapper.findComponent(GlModal); const findModal = () => wrapper.findComponent(GlModal);
const findPrimaryButton = () => wrapper.findComponent(GlButton);
const findForm = () => wrapper.find('form'); const findForm = () => wrapper.find('form');
const findFileInput = () => wrapper.findByLabelText('Upload CSV file'); const findFileInput = () => wrapper.findByLabelText('Upload CSV file');
const findAuthenticityToken = () => new FormData(findForm().element).get('authenticity_token'); const findAuthenticityToken = () => new FormData(findForm().element).get('authenticity_token');
...@@ -64,11 +64,11 @@ describe('CsvImportModal', () => { ...@@ -64,11 +64,11 @@ describe('CsvImportModal', () => {
expect(findForm().exists()).toBe(true); expect(findForm().exists()).toBe(true);
expect(findForm().attributes('action')).toBe(importCsvIssuesPath); expect(findForm().attributes('action')).toBe(importCsvIssuesPath);
expect(findAuthenticityToken()).toBe('mock-csrf-token'); expect(findAuthenticityToken()).toBe('mock-csrf-token');
expect(findFileInput()).toExist(); expect(findFileInput().exists()).toBe(true);
}); });
it('displays the correct primary button action text', () => { it('displays the correct primary button action text', () => {
expect(findPrimaryButton()).toExist(); expect(findModal().props('actionPrimary')).toEqual({ text: __('Import issues') });
}); });
it('submits the form when the primary action is clicked', () => { it('submits the form when the primary action is clicked', () => {
......
...@@ -456,7 +456,7 @@ describe('Dashboard', () => { ...@@ -456,7 +456,7 @@ describe('Dashboard', () => {
it('shows the links section', () => { it('shows the links section', () => {
expect(wrapper.vm.shouldShowLinksSection).toBe(true); expect(wrapper.vm.shouldShowLinksSection).toBe(true);
expect(wrapper.find(LinksSection)).toExist(); expect(wrapper.findComponent(LinksSection).exists()).toBe(true);
}); });
}); });
......
import { GlLink } from '@gitlab/ui'; import { GlLink } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import LinksSection from '~/monitoring/components/links_section.vue'; import LinksSection from '~/monitoring/components/links_section.vue';
import { createStore } from '~/monitoring/stores'; import { createStore } from '~/monitoring/stores';
...@@ -26,12 +28,12 @@ describe('Links Section component', () => { ...@@ -26,12 +28,12 @@ describe('Links Section component', () => {
createShallowWrapper(); createShallowWrapper();
}); });
it('does not render a section if no links are present', () => { it('does not render a section if no links are present', async () => {
setState(); setState();
return wrapper.vm.$nextTick(() => { await nextTick();
expect(findLinks()).not.toExist();
}); expect(findLinks().length).toBe(0);
}); });
it('renders a link inside a section', () => { it('renders a link inside a section', () => {
......
...@@ -15,12 +15,12 @@ describe('Text variable component', () => { ...@@ -15,12 +15,12 @@ describe('Text variable component', () => {
}); });
}; };
const findInput = () => wrapper.find(GlFormInput); const findInput = () => wrapper.findComponent(GlFormInput);
it('renders a text input when all props are passed', () => { it('renders a text input when all props are passed', () => {
createShallowWrapper(); createShallowWrapper();
expect(findInput()).toExist(); expect(findInput().exists()).toBe(true);
}); });
it('always has a default value', () => { it('always has a default value', () => {
......
...@@ -29,7 +29,7 @@ describe('monitoring/pages/dashboard_page', () => { ...@@ -29,7 +29,7 @@ describe('monitoring/pages/dashboard_page', () => {
}); });
}; };
const findDashboardComponent = () => wrapper.find(Dashboard); const findDashboardComponent = () => wrapper.findComponent(Dashboard);
beforeEach(() => { beforeEach(() => {
buildRouter(); buildRouter();
...@@ -60,7 +60,7 @@ describe('monitoring/pages/dashboard_page', () => { ...@@ -60,7 +60,7 @@ describe('monitoring/pages/dashboard_page', () => {
smallEmptyState: false, smallEmptyState: false,
}; };
expect(findDashboardComponent()).toExist(); expect(findDashboardComponent().exists()).toBe(true);
expect(allProps).toMatchObject(findDashboardComponent().props()); expect(allProps).toMatchObject(findDashboardComponent().props());
}); });
}); });
...@@ -58,7 +58,6 @@ describe('issue_note_body component', () => { ...@@ -58,7 +58,6 @@ describe('issue_note_body component', () => {
it('adds autosave', () => { it('adds autosave', () => {
const autosaveKey = `autosave/Note/${note.noteable_type}/${note.id}`; const autosaveKey = `autosave/Note/${note.noteable_type}/${note.id}`;
expect(vm.autosave).toExist();
expect(vm.autosave.key).toEqual(autosaveKey); expect(vm.autosave.key).toEqual(autosaveKey);
}); });
}); });
......
...@@ -33,12 +33,12 @@ describe('InstallationCommands', () => { ...@@ -33,12 +33,12 @@ describe('InstallationCommands', () => {
}); });
} }
const npmInstallation = () => wrapper.find(NpmInstallation); const npmInstallation = () => wrapper.findComponent(NpmInstallation);
const mavenInstallation = () => wrapper.find(MavenInstallation); const mavenInstallation = () => wrapper.findComponent(MavenInstallation);
const conanInstallation = () => wrapper.find(ConanInstallation); const conanInstallation = () => wrapper.findComponent(ConanInstallation);
const nugetInstallation = () => wrapper.find(NugetInstallation); const nugetInstallation = () => wrapper.findComponent(NugetInstallation);
const pypiInstallation = () => wrapper.find(PypiInstallation); const pypiInstallation = () => wrapper.findComponent(PypiInstallation);
const composerInstallation = () => wrapper.find(ComposerInstallation); const composerInstallation = () => wrapper.findComponent(ComposerInstallation);
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
...@@ -57,7 +57,7 @@ describe('InstallationCommands', () => { ...@@ -57,7 +57,7 @@ describe('InstallationCommands', () => {
it(`${packageEntity.packageType} instructions exist`, () => { it(`${packageEntity.packageType} instructions exist`, () => {
createComponent({ packageEntity }); createComponent({ packageEntity });
expect(selector()).toExist(); expect(selector().exists()).toBe(true);
}); });
}); });
}); });
......
...@@ -38,7 +38,7 @@ describe('Dropdown select component', () => { ...@@ -38,7 +38,7 @@ describe('Dropdown select component', () => {
it('creates a hidden input if fieldName is provided', () => { it('creates a hidden input if fieldName is provided', () => {
mountDropdown({ fieldName: 'namespace-input' }); mountDropdown({ fieldName: 'namespace-input' });
expect(findNamespaceInput()).toExist(); expect(findNamespaceInput().exists()).toBe(true);
expect(findNamespaceInput().attributes('name')).toBe('namespace-input'); expect(findNamespaceInput().attributes('name')).toBe('namespace-input');
}); });
...@@ -57,9 +57,9 @@ describe('Dropdown select component', () => { ...@@ -57,9 +57,9 @@ describe('Dropdown select component', () => {
// wait for dropdown options to populate // wait for dropdown options to populate
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
expect(findDropdownOption('user: Administrator')).toExist(); expect(findDropdownOption('user: Administrator').exists()).toBe(true);
expect(findDropdownOption('group: GitLab Org')).toExist(); expect(findDropdownOption('group: GitLab Org').exists()).toBe(true);
expect(findDropdownOption('group: Foobar')).not.toExist(); expect(findDropdownOption('group: Foobar').exists()).toBe(false);
findDropdownOption('user: Administrator').trigger('click'); findDropdownOption('user: Administrator').trigger('click');
await wrapper.vm.$nextTick(); await wrapper.vm.$nextTick();
......
...@@ -35,7 +35,7 @@ describe('Pipelines Empty State', () => { ...@@ -35,7 +35,7 @@ describe('Pipelines Empty State', () => {
}); });
it('should render the CI/CD templates', () => { it('should render the CI/CD templates', () => {
expect(pipelinesCiTemplates()).toExist(); expect(pipelinesCiTemplates().exists()).toBe(true);
}); });
}); });
......
...@@ -554,7 +554,7 @@ describe('Pipelines', () => { ...@@ -554,7 +554,7 @@ describe('Pipelines', () => {
}); });
it('renders the CI/CD templates', () => { it('renders the CI/CD templates', () => {
expect(wrapper.find(PipelinesCiTemplates)).toExist(); expect(wrapper.findComponent(PipelinesCiTemplates).exists()).toBe(true);
}); });
describe('when the code_quality_walkthrough experiment is active', () => { describe('when the code_quality_walkthrough experiment is active', () => {
...@@ -568,7 +568,7 @@ describe('Pipelines', () => { ...@@ -568,7 +568,7 @@ describe('Pipelines', () => {
}); });
it('renders the CI/CD templates', () => { it('renders the CI/CD templates', () => {
expect(wrapper.find(PipelinesCiTemplates)).toExist(); expect(wrapper.findComponent(PipelinesCiTemplates).exists()).toBe(true);
}); });
}); });
...@@ -597,7 +597,7 @@ describe('Pipelines', () => { ...@@ -597,7 +597,7 @@ describe('Pipelines', () => {
}); });
it('renders the CI/CD templates', () => { it('renders the CI/CD templates', () => {
expect(wrapper.find(PipelinesCiTemplates)).toExist(); expect(wrapper.findComponent(PipelinesCiTemplates).exists()).toBe(true);
}); });
}); });
......
...@@ -115,7 +115,7 @@ describe('Author Select', () => { ...@@ -115,7 +115,7 @@ describe('Author Select', () => {
}); });
it('does not have popover text by default', () => { it('does not have popover text by default', () => {
expect(wrapper.attributes('title')).not.toExist(); expect(wrapper.attributes('title')).toBeUndefined();
}); });
}); });
......
...@@ -134,12 +134,12 @@ describe('App component', () => { ...@@ -134,12 +134,12 @@ describe('App component', () => {
it('renders main-heading with correct text', () => { it('renders main-heading with correct text', () => {
const mainHeading = findMainHeading(); const mainHeading = findMainHeading();
expect(mainHeading).toExist(); expect(mainHeading.exists()).toBe(true);
expect(mainHeading.text()).toContain('Security Configuration'); expect(mainHeading.text()).toContain('Security Configuration');
}); });
it('renders GlTab Component ', () => { it('renders GlTab Component ', () => {
expect(findTab()).toExist(); expect(findTab().exists()).toBe(true);
}); });
it('renders right amount of tabs with correct title ', () => { it('renders right amount of tabs with correct title ', () => {
......
...@@ -50,7 +50,7 @@ describe('Issuable Time Tracking Report', () => { ...@@ -50,7 +50,7 @@ describe('Issuable Time Tracking Report', () => {
it('should render loading spinner', () => { it('should render loading spinner', () => {
mountComponent(); mountComponent();
expect(findLoadingIcon()).toExist(); expect(findLoadingIcon().exists()).toBe(true);
}); });
it('should render error message on reject', async () => { it('should render error message on reject', async () => {
......
...@@ -47,10 +47,12 @@ Object.assign(global, { ...@@ -47,10 +47,12 @@ Object.assign(global, {
setFixtures: setHTMLFixture, setFixtures: setHTMLFixture,
}); });
const JQUERY_MATCHERS_TO_EXCLUDE = ['toHaveLength', 'toExist'];
// custom-jquery-matchers was written for an old Jest version, we need to make it compatible // custom-jquery-matchers was written for an old Jest version, we need to make it compatible
Object.entries(jqueryMatchers).forEach(([matcherName, matcherFactory]) => { Object.entries(jqueryMatchers).forEach(([matcherName, matcherFactory]) => {
// Don't override existing Jest matcher // Exclude these jQuery matchers
if (matcherName === 'toHaveLength') { if (JQUERY_MATCHERS_TO_EXCLUDE.includes(matcherName)) {
return; return;
} }
......
...@@ -191,7 +191,7 @@ describe('MRWidgetMerged', () => { ...@@ -191,7 +191,7 @@ describe('MRWidgetMerged', () => {
}); });
it('shows button to copy commit SHA to clipboard', () => { it('shows button to copy commit SHA to clipboard', () => {
expect(selectors.copyMergeShaButton).toExist(); expect(selectors.copyMergeShaButton).not.toBe(null);
expect(selectors.copyMergeShaButton.getAttribute('data-clipboard-text')).toBe( expect(selectors.copyMergeShaButton.getAttribute('data-clipboard-text')).toBe(
vm.mr.mergeCommitSha, vm.mr.mergeCommitSha,
); );
...@@ -201,14 +201,14 @@ describe('MRWidgetMerged', () => { ...@@ -201,14 +201,14 @@ describe('MRWidgetMerged', () => {
vm.mr.mergeCommitSha = null; vm.mr.mergeCommitSha = null;
Vue.nextTick(() => { Vue.nextTick(() => {
expect(selectors.copyMergeShaButton).not.toExist(); expect(selectors.copyMergeShaButton).toBe(null);
expect(vm.$el.querySelector('.mr-info-list').innerText).not.toContain('with'); expect(vm.$el.querySelector('.mr-info-list').innerText).not.toContain('with');
done(); done();
}); });
}); });
it('shows merge commit SHA link', () => { it('shows merge commit SHA link', () => {
expect(selectors.mergeCommitShaLink).toExist(); expect(selectors.mergeCommitShaLink).not.toBe(null);
expect(selectors.mergeCommitShaLink.text).toContain(vm.mr.shortMergeCommitSha); expect(selectors.mergeCommitShaLink.text).toContain(vm.mr.shortMergeCommitSha);
expect(selectors.mergeCommitShaLink.href).toBe(vm.mr.mergeCommitPath); expect(selectors.mergeCommitShaLink.href).toBe(vm.mr.mergeCommitPath);
}); });
......
...@@ -16,6 +16,6 @@ describe('ContentViewer', () => { ...@@ -16,6 +16,6 @@ describe('ContentViewer', () => {
propsData: { path, fileSize: 1024, type }, propsData: { path, fileSize: 1024, type },
}); });
expect(wrapper.find(selector).element).toExist(); expect(wrapper.find(selector).exists()).toBe(true);
}); });
}); });
...@@ -42,7 +42,7 @@ describe('MarkdownViewer', () => { ...@@ -42,7 +42,7 @@ describe('MarkdownViewer', () => {
it('renders an animation container while the markdown is loading', () => { it('renders an animation container while the markdown is loading', () => {
createComponent(); createComponent();
expect(wrapper.find('.animation-container')).toExist(); expect(wrapper.find('.animation-container').exists()).toBe(true);
}); });
it('renders markdown preview preview renders and loads rendered markdown from server', () => { it('renders markdown preview preview renders and loads rendered markdown from server', () => {
......
...@@ -29,7 +29,7 @@ describe('~/whats_new/utils/notification', () => { ...@@ -29,7 +29,7 @@ describe('~/whats_new/utils/notification', () => {
subject(); subject();
expect(findNotificationCountEl()).toExist(); expect(findNotificationCountEl()).not.toBe(null);
expect(notificationEl.classList).toContain('with-notifications'); expect(notificationEl.classList).toContain('with-notifications');
}); });
...@@ -38,11 +38,11 @@ describe('~/whats_new/utils/notification', () => { ...@@ -38,11 +38,11 @@ describe('~/whats_new/utils/notification', () => {
notificationEl.classList.add('with-notifications'); notificationEl.classList.add('with-notifications');
localStorage.setItem('display-whats-new-notification', 'version-digest'); localStorage.setItem('display-whats-new-notification', 'version-digest');
expect(findNotificationCountEl()).toExist(); expect(findNotificationCountEl()).not.toBe(null);
subject(); subject();
expect(findNotificationCountEl()).not.toExist(); expect(findNotificationCountEl()).toBe(null);
expect(notificationEl.classList).not.toContain('with-notifications'); expect(notificationEl.classList).not.toContain('with-notifications');
}); });
}); });
......
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