Skip to content

'Disabled' attribute on buttons is ignored during testing #395

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

Closed
jamesoshea opened this issue Jan 29, 2018 · 2 comments · Fixed by #424
Closed

'Disabled' attribute on buttons is ignored during testing #395

jamesoshea opened this issue Jan 29, 2018 · 2 comments · Fixed by #424

Comments

@jamesoshea
Copy link
Contributor

Version

1.0.0-beta.11

Reproduction link

https://github.com/jamesoshea/vue-test-utils-button-bug

Steps to reproduce

Run npm install, then npm test. The test will fail as vue-test-utils trigger a click on a disabled element, and the element's bound method is called anyway.

What is expected?

The method should not get called when the button is clicked.

What is actually happening?

When testing a vue component, I will sometimes call .trigger('click') on a wrapper containing just a button. If the button is disabled and a method is bound to its click event, the button is clicked and the method called anyway.

@eddyerburgh
Copy link
Member

Thanks for the bug report 😀

We trigger events using the dispatchEvent method. This doesn't respect disabled elements, as you found out.

To fix this, we'll need to add a check inside the trigger method.

@jamesoshea
Copy link
Contributor Author

I'd be happy to put in a PR! Thanks to yourself and everyone behind this library, it's been a lifesaver 😄

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

Successfully merging a pull request may close this issue.

2 participants