-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Labels
pkg/driverThis is due to an issue in the packages/driver directoryThis is due to an issue in the packages/driver directorytopic: cy.type ⌨️
Description
Current behavior:
Testing a code who used event instanceof KeyboardEvent, I've seen some strange behavior, digging up, it seems that there is some strange inconsistencies between the events triggered and also into the way they are sent to the eventListener.
Desired behavior:
Consistent behavior:
.type.trigger({..., type: 'keydown'}).get('#element').then(element.dispatchEvent(new KeyboardEvent('keydown', ...)))
Should all send a KeyboardEvent type event.
And the eventListener:
element.addEventListener('keydown', (event) => (event instanceof KeyboardEvent));Should always return true.
Steps to reproduce: (app code and test code)
I've tested three different methods: cy.type, cy.trigger, cy.get('#element').then( element.dispatchEvent).
And two different eventListener for each test:
- One directly into a <script> inside the html page itself
- One created into the test itself using
cy.get -> addEventListener
You can find MWE here: https://github.com/avallete/cypress-test-tiny-event-bug
Simply run:
npm install
npm run cypress:open
# Then run the test and check the console.log inside the debuging tools.
# Each test is a specific case the 2 first show that event is type Event instead of KeyboardEvent.
# The third test show the inconsistency of the same eventListener if it's declared inside the test or outside (into the html <script>).
Versions
3.6.1, Linux, Chromium 78 / Electron 73
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
pkg/driverThis is due to an issue in the packages/driver directoryThis is due to an issue in the packages/driver directorytopic: cy.type ⌨️