I am attempting to include custom commands in my Cypress tests using typescript. It just seems so difficult to get it to work. I have moved the files in various folders but it is simply a frustrating experience. It shouldn't be this hard. Here is the structure of my project: I am using version 12.14.0 of Cypress and Typescript
In my support folder, I have the following files
cypress
support
e2e.ts
index.d.ts. // declare namespace Cypress with definitions of commands
accounts-cmd.ts // has Cypress.Command.add(.....)
fixtures
tests // my tests are in here
accounts.cy.ts // uses custom command findByAccountsId(id: string)
//tsconfig.json
types: ["cypress", "./support"]
//cypress.config.ts
supportFile: "./support/e2e.ts",
I have my a declaration in the index.d.ts called findAccountsById(id: string) which returns a Chainable from and axios call. It is defined like this
findByAccountId(id: string): Chainable<Response>;
In my accounts-cmd.ts I reference the index.d.ts
/// <reference path="./index.d.ts" />