cypress-msw-interceptor
cypress-msw-interceptor copied to clipboard
Adding typings?
trafficstars
Hi,
Could you adding typings to this library?
I've setup the following myself
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Cypress {
interface Chainable {
waitForRequest(alias: string): Chainable<{ id: string, request: MockedRequest, complete: boolean }>;
waitForQuery(alias: string): Chainable<{ id: string, request: MockedRequest, complete: boolean }>;
waitForMutation(alias: string): Chainable<{ id: string, request: MockedRequest, complete: boolean }>;
getRequestCalls(alias: string): Chainable<void>;
getQueryCalls(alias: string): Chainable<void>;
getMutationCalls(alias: string): Chainable<void>;
interceptRequest(type, route, ...args): Chainable<string>;
interceptQuery(name, ...args): Chainable<string>;
interceptMutation(name, ...args): Chainable<string>;
}
}
}
The PR is interesting. I have used only
namespace Cypress {
interface Chainable {
waitForRequest(alias: string): Chainable<{ id: string, request: MockedRequest, complete: boolean }>;
waitForQuery(alias: string): Chainable<{ id: string, request: MockedRequest, complete: boolean }>;
waitForMutation(alias: string): Chainable<{ id: string, request: MockedRequest, complete: boolean }>;
getRequestCalls(alias: string): Chainable<void>;
getQueryCalls(alias: string): Chainable<void>;
getMutationCalls(alias: string): Chainable<void>;
interceptRequest(type, route, ...args): Chainable<string>;
interceptQuery(name, ...args): Chainable<string>;
interceptMutation(name, ...args): Chainable<string>;
}
}
in a global.d.ts file, and it works well.
In Visual Studio Code the Cypress Helper (latest) extension is meant to parse custom commands, but for the cypress-msw-interceptor project, it did not work despite providing src/cypress/support as a custom commands folder path.