cypress-mailhog icon indicating copy to clipboard operation
cypress-mailhog copied to clipboard

Support custom `mhGetMailsByFilter`

Open MDG-JHowley opened this issue 6 months ago • 0 comments

This would allow complex filters while getting the benefits of retryability. It would also solve the problem of chaining filters not being retryable.

e.g.

Cypress.Commands.add('mhGetMailsByFilter', (filter = mails => mails, limit = 50, options = {}) => {
  return retryFetchMessages(getMessages, filter, limit, options);
});

// retryable filter by subject and recipient
cy.mhGetMailsByFilter(mails => {
    return mails.filter(mail => mail.To.map(recipientObj => `${recipientObj.Mailbox}@${recipientObj.Domain}`).includes(recipient) && mail.Content.Headers.Subject[0] === subject);
})

MDG-JHowley avatar Jul 30 '24 14:07 MDG-JHowley