Skip to content
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

Large increase in random CI failures using Cypress after upgrading to react-router v7 #12974

Open
pjg opened this issue Feb 7, 2025 · 2 comments
Labels

Comments

@pjg
Copy link

pjg commented Feb 7, 2025

I'm using React Router as a...

library

Reproduction

There are no reproduction steps. Just an observation. Looking at video of failures, and corresponding code, it looks like a race condition during clicking. The code failing looks similar to this (in various places):

cy.contains('Text').should('exist')
cy.get('.class a').first().click()

The link is on the same page as the text. What happens is that Cypress executes the click, but react-router does not transition to the new path, like the click never happened.

I'm posting this mainly to see if I'm alone with this.

System Info

react-router v7.1.4
cypress v14.0.1

Used Package Manager

npm

Expected Behavior

Not seeing random test failures.

Actual Behavior

Seeing random test failures.

@pjg pjg added the bug label Feb 7, 2025
@timdorr
Copy link
Member

timdorr commented Feb 7, 2025

Does it transition to the new page if you add some wait time to the test?

We use startTransition between navigations, so this introduces potentially async behavior to rendering. You may either need to wait a tick for the render to finish or have some way to wait for the render to finish before checking the DOM state. That may depend on how you have the test renderer hooked up and what libraries you use to do that.

@pjg
Copy link
Author

pjg commented Feb 9, 2025

It's hard to tell as the failures are very random across the whole test suite. I use cypress, and it has some waiting mechanisms built-in, so that there's no need to manually wait. Though they seem to fail occasionally when dealing with react-router v7. I'll keep investigating though.

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

No branches or pull requests

2 participants