Quantcast
Viewing latest article 31
Browse Latest Browse All 54

Answer by totymedli for Cypress custom command is not recognized when invoked

tl;dr

Wrap the Cypress.Commands.adds to a function then import and run it.

Explanation

I had all my Cypress.Commands.adds in the support/commands.ts file. This was imported in support/e2e.ts with import './commands'; which worked fine until a recent dependency upgrade. To make it work again I modified the support/commands.ts file so it looks like this:

export default function addCustomCommands() {  // all the Cypress.Commands.add calls}

Then imported and executed this function in the support/e2e.ts file:

import addCustomCommands from './commands';addCustomCommands();

Viewing latest article 31
Browse Latest Browse All 54

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>