dmtrKovalenko / cypress-real-events

Fire native system events from Cypress.
MIT License
738 stars 67 forks source link

Flakiness with realPress #678

Closed philipbushnell-valtech closed 1 month ago

philipbushnell-valtech commented 1 month ago

It seems that realPress doesn't always trigger the focused element. I have the following code:

cy.findByRole('button', { name: 'Open' }).focus();

// passes always
cy.findByRole('button', { name: 'Open' }).should('be.focused'); 

cy.realPress('Enter');

// fails sometimes as the menu is not actually opened by the press
cy.findByRole('heading', { name: 'Heading Text' }).should('be.visible'); 

I'm on the latest version (1.12.0) and this is quite frustrating when it fails. I'm explicitly checking keyboard navigation so I cannot replace it with click.

dmtrKovalenko commented 1 month ago

I need a more descriptive standalone example. Please make a repo that clearly displays the flakieness

philipbushnell-valtech commented 1 month ago

That's the issue, it's flaky. You could run it 50 times and it passes fine but then on the 51st time it'll fail so there's no way to clearly display it for you. There's nothing special or exciting about the code; it's just a button with an onClick handler that causes a rerender to now make something visible.

dmtrKovalenko commented 1 month ago

I won't be able to look into the issue until there would be a clear concise reproduction of flakieness.