cypress-testing-library icon indicating copy to clipboard operation
cypress-testing-library copied to clipboard

Doesn't work with Cypress 13.4.0 due to `addQuery` usage

Open brycefranzen opened this issue 1 year ago • 3 comments

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

Relevant code or config:

https://github.com/testing-library/cypress-testing-library/blob/0f2f002907d61712de8f46e9a4115cfb12e58eec/src/add-commands.js#L4

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 avatar Nov 01 '23 16:11 brycefranzen