vue-js-toggle-button icon indicating copy to clipboard operation
vue-js-toggle-button copied to clipboard

Not able to test using jest

Open gokulakshay opened this issue 4 years ago • 1 comments
trafficstars

await wrapper.findComponent({ ref: "videoScaleToggle" }).trigger("click");

or

await wrapper.findComponent({ ref: "videoScaleToggle" }).trigger("change");]

these dont work in jest

gokulakshay avatar Oct 26 '21 18:10 gokulakshay

For anyone else reaching this issue with the same problem: To be able to trigger an event on the toggle button, I just attached a selector to it

<toggle-button data-test-id="toggle" />

While inspecting the HTML produced, I noticed that the selector was being attached to a <label> which wraps the <input type="checkbox">. Something lke

<label data-test-id="toggle">
  <input type="checkbox" />
</label>

So I updated the toggle value by calling

wrapper.find(`[data-test-id="toggle"] input`).setChecked(true)

silvaptk avatar Mar 13 '23 15:03 silvaptk