Quantcast
Channel: User totymedli - Stack Overflow
Viewing all articles
Browse latest Browse all 44

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

$
0
0

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 all articles
Browse latest Browse all 44

Trending Articles