-
Notifications
You must be signed in to change notification settings - Fork 668
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
Triggering a "click" on a button with type="submit" doesn't fire the "submit" event on the containing form #1278
Comments
You can trigger submit instead of click.
|
Well sure, but I'd my test to not make assumptions about the code. For instance, perhaps the submit code happens on a click listener on the button or it happens on the form submission. Either way clicking the button would do the right thing in the production environment, so I want to write my tests in a way that doesn't assume the how, just the what. |
@thejcannon Well, based on your code, your are listening to, "submit," event.
So, I would say finding the button and triggering a submit, would reflect your code. Or you can listen to "click," event if that's what you want. Oh, one thing, If I'm not mistaken, you are not, "clicking" on a button in your tests, you are triggering an event. |
@thejcannon this is a problem with The problem is that Edit: I was wrong, Edit 2: It's jest's fault: |
So I think we can close this, @thejcannon , since it is unrelated to |
Yep, I had this problem recently. It's jsdom! Bugs are few and far in jssom, which is a remarkable - implementing a whatwg dom is an extremely complex endeavor. Anyway, I just use If someone can reproduce this with jest 25 (you need to install https://www.npmjs.com/package/jest-environment-jsdom-sixteen) please comment and we will reopen this. |
Version
1.0.0-beta.29
Reproduction link
https://codesandbox.io/s/vue-template-2txst
Steps to reproduce
(I can't seem to get the tests to not fail with "Cannot read property 'Ctor' of undefined")
Once the tests work though, simply running them should outline the bug.
What is expected?
When I click the "submit" button, the form "submit" listener to be called.
What is actually happening?
It isn't being called.
The text was updated successfully, but these errors were encountered: