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

Doesn't work with Cypress 13.4.0 due to addQuery usage #268

Open
brycefranzen opened this issue Nov 1, 2023 · 3 comments
Open

Doesn't work with Cypress 13.4.0 due to addQuery usage #268

brycefranzen opened this issue Nov 1, 2023 · 3 comments

Comments

@brycefranzen
Copy link

  • cypress-testing-library version: 10.0.1
  • node version: 16.17.0
  • npm (or yarn) version: 8.15.0

Relevant code or config:

Cypress.Commands.addQuery(name, command)

commands.forEach(({name, command}) => {
  Cypress.Commands.addQuery(name, command)
})

What you did:
Update cypress to latest version (13.4.0).
Update @testing-library/cypress to latest version (10.0.1)

What happened:
Cypress started in gui mode without issues. When running a test, it fails with the following error:

The following error originated from your test code, not from Cypress.



  > Cypress.Commands.addQuery() is used to create new queries, but findAllByLabelText is an existing Cypress command or query, or is reserved internally by Cypress.



 If you want to override an existing command or query, use Cypress.Commands.overrideQuery() instead.



When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.



Cypress could not associate this error to any specific test.

Reproduction repository:
Already described above under what you did

Problem description:
Looks like testing-library is trying to recreate a function that already exists in cypress.

Suggested solution:
Either use the built in method from cypress, or use Cypress.Commands.overrideQuery() instead in this case.

@brycefranzen
Copy link
Author

After further reading error logs, it appears this may actually be an issue in the https://github.com/kentcdodds/dom-testing-library repo. I assumed it was here since the error was thrown within the scope of this repos code. However, it appears that the offending code that caused the error may be in the other repo after-all 🤷🏼‍♂️

If that's the case, feel free to close/recreate this issue over there.

Thanks!

@Oputo50
Copy link

Oputo50 commented Nov 9, 2023

I'm facing the exact same issue. Any idea of how to workaround it?

@rszalski
Copy link

Ran into the same issue. Looks like there already is a GH issue for this with more details and potential solution: #251.

I suggest this is closed as a duplicate.

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

No branches or pull requests

3 participants