Commit df0d8f2c authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'remove-jest-custom-jquery-matchers' into 'master'

Don't use toHaveLength matcher from custom-jquery-matchers

See merge request gitlab-org/gitlab!20350
parents 37f8a7f0 89c247f2
......@@ -113,10 +113,10 @@ describe('DependenciesApp component', () => {
const expectNoHeader = () => expect(findHeader().exists()).toBe(false);
const expectDependenciesTables = () => {
const { wrappers } = findDependenciesTables();
expect(wrappers).toHaveLength(2);
expect(wrappers[0].props()).toEqual({ namespace: allNamespace });
expect(wrappers[1].props()).toEqual({ namespace: vulnerableNamespace });
const tables = findDependenciesTables();
expect(tables).toHaveLength(2);
expect(tables.at(0).props()).toEqual({ namespace: allNamespace });
expect(tables.at(1).props()).toEqual({ namespace: vulnerableNamespace });
};
const expectHeader = () => {
......
......@@ -42,10 +42,11 @@ describe('LogControlButtons', () => {
expect(findRefreshBtn().is(GlButton)).toBe(true);
});
it('emits a `refresh` event on click on `refersh` button', () => {
it('emits a `refresh` event on click on `refresh` button', () => {
initWrapper();
expect(wrapper.emitted('refresh')).toHaveLength(0);
// An `undefined` value means no event was emitted
expect(wrapper.emitted('refresh')).toBe(undefined);
findRefreshBtn().vm.$emit('click');
......
......@@ -57,6 +57,11 @@ Object.assign(global, {
// custom-jquery-matchers was written for an old Jest version, we need to make it compatible
Object.entries(jqueryMatchers).forEach(([matcherName, matcherFactory]) => {
// Don't override existing Jest matcher
if (matcherName === 'toHaveLength') {
return;
}
expect.extend({
[matcherName]: matcherFactory().compare,
});
......
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