Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to test using jest #165

Open
gokulakshay opened this issue Oct 26, 2021 · 1 comment
Open

Not able to test using jest #165

gokulakshay opened this issue Oct 26, 2021 · 1 comment

Comments

@gokulakshay
Copy link

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

or

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

these dont work in jest

@silvaptk
Copy link

silvaptk commented Mar 13, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants