This repository has been archived by the owner on Jan 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Typescript: Cannot both import onlyOn and use cy.onlyOn #164
Comments
Looks like the types aren't being added to the declare namespace Cypress {
// ... type definitions
} To this: declare global {
declare namespace Cypress {
// ... type definitions
}
} |
Any update on this? thanks! |
I was able to successfully import both by exporting the global scope in my Try the following:
You can also find a minimal reproducible example here: https://github.com/conversaShawn/using-cypress-skip-test-plugin/tree/onlyOn |
Add to your cypress.d.ts file export {}
declare global {
namespace Cypress {
interface Chainable<Subject> {
/// plugins ///
// the cypress skip-test plugin has an open issue with types, that is we have declare these here
// https://github.com/cypress-io/cypress-skip-test/issues/164
/** https://www.npmjs.com/package/@cypress/skip-test
* `cy.skipOn('sandbox')`
*/
skipOn(
nameOrFlag: string | boolean | (() => boolean),
cb?: () => void,
): Chainable<Subject>
/** https://www.npmjs.com/package/@cypress/skip-test
* `cy.onlyOn('sandbox')`
*/
onlyOn(
nameOrFlag: string | boolean | (() => boolean),
cb?: () => void,
): Chainable<Subject>
}
}
} |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
In v2.6.0, Typescript threw errors when
onlyOn
was imported, but worked correctly forcy.onlyOn
. Now in v2.6.1 (after #143), Typescript correctly types theonlyOn
import, butcy.onlyOn
does not have a type.Is there any way to get both of these to work with Typescript?
The text was updated successfully, but these errors were encountered: