synpress icon indicating copy to clipboard operation
synpress copied to clipboard

Cypress Commands adddQuery Error

Open jmitchell-figure opened this issue 2 years ago • 5 comments

Describe the bug When going through the examples to setup within Cypress I am seeing the following error when trying to run any tests:

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

To Reproduce

  1. Go through installation instructions.
  2. Use Cypress example for setup: https://github.com/drptbl/synpress-examples/tree/master/cypress/isolated-state
  3. Run any test.
  4. See error

**Expected behavior Cypress should run tests without the error.

Screenshots image

Desktop (please complete the following information):

  • OS: macOS
  • Synpress version: 3.5.1

**Note Cypress Version: 12.5.1

jmitchell-figure avatar Apr 12 '23 23:04 jmitchell-figure

Bump, this is also happening to me

nickwang14 avatar Apr 25 '23 19:04 nickwang14

Take a look at this https://github.com/testing-library/cypress-testing-library/pull/238#issuecomment-1366904058. This error happened on my side when I was importing e2e.ts file in my tests and we have a query type defined in e2e.ts. So pay attention if you import in your test file rather the type definition or anything from commands.ts, where the query is added

yelenabaghdasaryan avatar Apr 27 '23 12:04 yelenabaghdasaryan

This is happening to me also. https://github.com/testing-library/cypress-testing-library/pull/238#issuecomment-1366904058 this didn't help me unfortunately

Oputo50 avatar Nov 08 '23 10:11 Oputo50

@jmitchell-figure have you been able to fix it?

Oputo50 avatar Nov 08 '23 10:11 Oputo50

Take a look at this https://github.com/testing-library/cypress-testing-library/pull/238#issuecomment-1366904058.

I had the same error and the fix was also to ensure that the file was "run" only once.
I suggest anyone facing this issue to just add a console.log before adding the commands/queries:

console.log('Adding support commands/queries');  // => If you see this log multiple times, the issue is likely on your end
Cypress.Commands.addQuery('findAllByLabelText', findAllByLabelTextFn);

devfservant avatar Nov 30 '23 09:11 devfservant