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

> Cypress.Commands.add() is used to create new commands, but debug is an existing Cypress command. #97

Closed
mrityunjeyan opened this issue Dec 20, 2021 · 7 comments · Fixed by #102

Comments

@mrityunjeyan
Copy link

I am using cypress 9.1.1 version and requiring require('@reportportal/agent-js-cypress/lib/commands/reportPortalCommands');

is throwing me the following error

An uncaught error was detected outside of a test:
     CypressError: The following error originated from your test code, not from Cypress.

  > `Cypress.Commands.add()` is used to create new commands, but `debug` is an existing Cypress command.

Please use `Cypress.Commands.overwrite()` if you would like to overwrite an existing command.

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.

We dynamically generated a new test to display this failure.

https://on.cypress.io/custom-commands
@sakshi-tawani
Copy link

Facing same issue

@AmsterGet AmsterGet linked a pull request Jan 21, 2022 that will close this issue
@zvpanchal
Copy link

Hi, when will this issue fix be merged to the master? We are facing the same issue.

@AmsterGet
Copy link
Member

Fixed in 5.0.3.

@AnkaNik
Copy link

AnkaNik commented Jul 24, 2023

I have this issue with cypress 12.17.1

@AmsterGet
Copy link
Member

Hello @AnkaNik !
Which version agent-js-cypress are you using?
Please note we've added the logDebug command instead of overriding default Cypress debug.

@AnkaNik
Copy link

AnkaNik commented Jul 24, 2023

Hello @AnkaNik ! Which version agent-js-cypress are you using? Please note we've added the logDebug command instead of overriding default Cypress debug.

Im not sure that I know how to find it because just start use it after long pause)

I face problem with error :

 CypressError: 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.
We dynamically generated a new test to display this failure
```.

when try to run synpress in my project. 

I've got all configuration setup as it is on tutorials, but when try to run `synpress run --configFile synpress.config.js` cypress loads and failed with error on a first step with initiated command for running metamask setup from synpress. 

My expectation was, that if I put inside support files import of synpress it will run smoothly)) 

here is **cypress/suport.index.js** file: 


_import "./commands.js"_
_import "@synthetixio/synpress/support"_


**cypress/support/commands.js**


_import "@testing-library/cypress/add-commands";_
// here go(es) your custom function(s)
_import "@synthetixio/synpress/support";_


**synpress.config.js** file:
 
_const { defineConfig } = require("cypress");

module.exports = defineConfig({
  userAgent: "synpress",

  retries: {
    runMode: 0,
    openMode: 0,
  },
 
  screenshotsFolder: "screenshots",
  videosFolder: "videos",
  video: true,
  chromeWebSecurity: true,
  viewportWidth: 1466,
  viewportHeight: 1200,

  env: {
    coverage: false,
  },
  
  defaultCommandTimeout: 30000,
  pageLoadTimeout: 30000,
  requestTimeout: 30000,

  component: {
    setupNodeEvents(on, config) {},
    specPattern: "./**/*spec.{.cy.js,jsx,ts,tsx}",
  },

  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
    supportFile: "cypress/support/index.js",
  },
});_


test file is **cypress/e2e/app/login.cy.js**

describe('Metamask Extension tests', () => {

// Define the test case "connect to DApp with Metamask extension example"
it('connect to DApp with Metamask extension example', () => {
  
  // Add a new network to Metamask using the `cy.addMetamaskNetwork()` command
  cy.addMetamaskNetwork({
    networkName: 'Optimism Goerli',
    rpcUrl: 'https://goerli.optimism.io',
    chainId: '420',
    symbol: 'ETH',
    blockExplorer: 'https://goerli-optimism.etherscan.io/',
    isTestnet: true,
  })
  
  // Visit the root URL of the DApp
  cy.visit('/myURL');
  //wait until it will be loading
  cy.wait(9000);
  cy.get('#accept-all-cookies').click();
  // Click the "Connect" button on the DApp
  cy.get('#heap-connect-wallet').click();
  cy.get('#metamask').click();

Maybe something I miss in configuration that is why it does not recognise correct commands..
Thanks!

@AmsterGet
Copy link
Member

I don't see any usages of our library (agent-js-cypress), so the issue is not related to this repo.

Anyway, looks like you need to check "./commands.js" or "@synthetixio/synpress/support" that you mentioned in cypress/suport.index.js to find the Cypress command collision.

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

Successfully merging a pull request may close this issue.

5 participants