-
Notifications
You must be signed in to change notification settings - Fork 3.4k
feat: can dispatch events with the type they want. #8305
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
Conversation
|
Thanks for taking the time to open a PR!
|
67dc534 to
4c109bf
Compare
packages/driver/cypress/integration/commands/actions/trigger_spec.js
Outdated
Show resolved
Hide resolved
a6a671a to
19eac4f
Compare
|
I'm not totally in love with calling this option But, looking through all the docs for this it seems they mostly refer to this as an 'interface', see https://w3c.github.io/uievents/#interface-keyboardevent Would an 'interface' key even make sense? Probably not. @chrisbreiding any thoughts? Maybe the current naming is harmless. |
I agree that's problematic and could be confusing. I don't think I like We could use cy.trigger('mousedown', {
constructor: 'MouseEvent',
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sainthkh What do you think of the name constructor for this new option?
|
I think it's better. It's less confusing. I'll change it that way. |
|
You can check it out by just opening a console window and try the code below: I thought of writing code like below to avoid this problem, but it's too unintuitive. const constructor = typeof options.constructor === 'string' ? options.constructor : 'Event' I came to the conclusion that we cannot use the name, My proposal: How about naming it |
|
😞 maybe |
|
I was worried that would be an issue. Let's go with |
This reverts commit e1455d8.
|
Flaky failures. |


User facing changelog
Users can dispatch events with the type they want. And the event is an instance of
UIEvent,viewproperty is filled with AUTwindow.Additional details
Why was this change necessary?
Eventwithcy.trigger(). But it was impossible.viewproperty didn't replicate the behavior of the browsers.What is affected by this change?
N/A
Any implementation details to explain?
At first, I tried to implement this with an object map like below:
Because
triggercan find the correct automatically. But the problem is that most of the properties ofEvents are read-only. They cannot be modified even with_.extend.It's a big problem because you cannot fire
MouseEventlike:MouseEventconstructor doesn't getpageXandpageYproperties and they are automatically set to the values ofclientXandclientY.So, I had to give up
eventMapand introduceeventTypeoption instead.How has the user experience changed?
PR Tasks
cypress-documentation? => Update trigger doc with new eventConstructor option cypress-documentation#3078type definitions?cypress.schema.json?