Skip to content

Add jQuery matchers to Jest

Inactive Account requested to merge winh-jest-jquery-matchers into master

What does this MR do?

Adds the same matchers that we currently have via jasmine-jquery in Karma to Jest.

What are the relevant issue numbers?

closes https://gitlab.com/gitlab-org/gitlab-ce/issues/59637

Before

FAIL spec/frontend/reports/components/report_section_spec.js
  ● Report section › with success status › toggleCollapsed › toggles issues

    TypeError: expect(...).not.toHaveCss is not a function

      134 |         Vue.nextTick()
      135 |           .then(() => {
    > 136 |             expect(vm.$el.querySelector('.js-report-section-container')).not.toHaveCss(hiddenCss);
          |                                                                              ^
      137 |             expect(vm.$el.querySelector('button').textContent.trim()).toEqual('Collapse');
      138 | 
      139 |             vm.$el.querySelector('button').click();

      at toHaveCss (spec/frontend/reports/components/report_section_spec.js:136:78)

  ● Report section › with success status › toggleCollapsed › is always expanded, if always-open is set to true

    TypeError: expect(...).not.toHaveCss is not a function

      152 |         Vue.nextTick()
      153 |           .then(() => {
    > 154 |             expect(vm.$el.querySelector('.js-report-section-container')).not.toHaveCss(hiddenCss);
          |                                                                              ^
      155 |             expect(vm.$el.querySelector('button')).toBeNull();
      156 |           })
      157 |           .then(done)

      at toHaveCss (spec/frontend/reports/components/report_section_spec.js:154:78)

(https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/187950242)

After

PASS spec/frontend/reports/components/report_section_spec.js

(https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/188063673)

Does this MR meet the acceptance criteria?

Edited by Inactive Account

Merge request reports