Skip to content

Instantly share code, notes, and snippets.

@alfredlucero
Last active April 30, 2024 11:40
Show Gist options
  • Save alfredlucero/4d1201c9f43dcf71931f8f3b8dc7d514 to your computer and use it in GitHub Desktop.
Save alfredlucero/4d1201c9f43dcf71931f8f3b8dc7d514 to your computer and use it in GitHub Desktop.
Cypress Tips/Tricks - Typing Task Plugin Functions
// Can import types from other files using TypeScript's typed imports functionality
type BlocksDto = import("../plugins/Suppressions/setup").BlocksDto;
// Or you can define the types here as well in this type definition file
type ApiHost = "https://staging.api.com" | "https://testing.api.com" | string;
declare namespace Cypress {
interface Cypress {
// ...environment variables
}
interface Chainable<Subject> {
// ...custom commands
task(
event: 'teardownUnverifiedDomains',
arg: {
username: string;
token: string;
},
options?: Partial<Loggable & Timeoutable>
): Chainable<boolean>;
task(
event: 'getBlocks',
arg: { token: string; apiHost: ApiHost; limit: number },
options?: Partial<Loggable & Timeoutable>
): Chainable<BlocksDto>;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment