mailosaur / cypress-mailosaur

Mailosaur email and SMS testing commands for Cypress

Home Page:https://mailosaur.com/docs/frameworks-and-tools/cypress/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Typescript types

drewbrend opened this issue · comments

Hello, I just started using cypress-mailosaur. All my code is TypeScript so I've had to add the types in my project. If these were added to the library it'd be ideal. I don't have the time to do this right now, but here is what I've added in my project. If no one else has picked this up I may do it in the future:

export interface MailosaurCriteria {
  /** The full email address to which the target email was sent. */
  sentTo?: string,
  /** The value to seek within the target email’s subject line. */
  subject?: string,
  /** The value to seek within the target email’s HTML or text body. */
  body?: string,
  /** If set to ALL (default), then only results that match all specified criteria will be returned.
   * If set to ANY, results that match any of the specified criteria will be returned. */
  match?: "ALL" | "ANY",
}

export interface MailosaurOptions extends Cypress.Timeoutable {
  receivedAfter?: Date,
  page?: number,
  itemsPerPage?: number,
  suppressError?: boolean
}

declare global {
  namespace Cypress {
    interface Chainable {
      mailosaurGetMessage(
        serverId: string,
        criteria: MailosaurCriteria,
        options?: MailosaurOptions
      ): Cypress.Chainable<Message>; // Message is imported from mailosaur lib here: https://github.com/mailosaur/mailosaur-node/blob/master/lib/models/index.d.ts#L176-L189
    }
  }
}
commented

Thanks @drewbrend. We will see if we can get this into one of our upcoming sprints 👍

commented

Hey @drewbrend we've added a type definition file to v1.0.7 so you can check it out now. If you find any issues with it please do get in touch.