tl;dr
Wrap the Cypress.Commands.add
s to a function then import and run it.
Explanation
I had all my Cypress.Commands.add
s 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();