cypress-mailhog
cypress-mailhog copied to clipboard
Support custom `mhGetMailsByFilter`
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);
})