cypress-msw-interceptor icon indicating copy to clipboard operation
cypress-msw-interceptor copied to clipboard

Adding typings?

Open wingy3181 opened this issue 2 years ago • 1 comments
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>;
    }
  }
}

wingy3181 avatar Dec 22 '22 23:12 wingy3181

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.

myselfhimself avatar Mar 22 '23 12:03 myselfhimself