cypresscypress-testing-librarymailhog

What can I do if parsing a test email is taking too long?


I plan to test a confirmation email with Cypress and MailHog. In principle, a few attributes and values should be present there. In a test mail that is about 200 K in size, the following code worked perfectly.

it.only('The body of a confirmation mail shall contain strings (Kaufland)', () => {

    cy.mhGetMailsBySubject('Deine Bestellung bei TODO.de')
      .mhFirst()
      .mhGetBody()
      .should('contain', 'Kunden-Nr')
      .should('contain', 'Bestelldatum')
      .should('contain', 'Bestellnummer')
      .should('contain', 'Zwischensumme')
      .should('contain', 'Versandkosten')
      .should('contain', 'Gesamtpreis')
      .should('contain', 'Lieferadresse')
      .should('contain', 'Rechnungsadresse')
      .should('contain', 'Widerrufsbelehrung')
  })

Now, I have another customer's email, which is a bit bulky and very convoluted and layered. Tables upon tables. However, it is also only 324K in size.

While that of the first customer is checked in a few seconds, Cypress hangs up when parsing the 2nd e-mail, or brings no result even after more than 2 minutes.

What options do I have here?


Solution

  • Another thing to note, .should() does a retry when it fails - but it's really only useful for asynchronous pages.

    Since you already have the full text available, change .should() to .then() which will not retry and therefore fail a lot faster.

    cy.mhGetMailsBySubject('Deine Bestellung bei TODO.de')
      .mhFirst()
      .mhGetBody()
      .then(body => {
        expect(body).to.contain('Kunden-Nr')  //  no retry 
        // etc