bahmutov / local-cypress

Use Cypress without global objects
https://glebbahmutov.com/blog/local-cypress/
33 stars 3 forks source link

Custom command types #43

Open rndmerle opened 2 years ago

rndmerle commented 2 years ago

Hi and thanks for this package, this is coming in handy. Any way to declare types for custom commands and chai-subsets ? Extending Cypress.Chainable and Cypress.Chainer interfaces the classic way in a .d.ts doesn't seem to work.

rndmerle commented 2 years ago

Well, actually with a .ts test file instead of .js is working alright.

brianbento commented 2 years ago

@rndmerle Could you explain what you did? I'm having some issues.

rndmerle commented 2 years ago

Well nothing fancy.

test/dts/cypress-commands.d.ts :

declare namespace Cypress {
  interface Chainable {
    $whatever(): Chainable<any>
  }
}

tsconfig.json :

"typeRoots": ["node_modules/@types", "test/__dts__"],
"include": [
  // ... other source directories
  "test/**/*.ts",
]

If it doesn't help, maybe could you provide a minimal repo reproducing the issue?