Michael S.
Michael S.

Reputation: 701

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?

Upvotes: 2

Views: 198

Answers (2)

Fody
Fody

Reputation: 31904

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

Upvotes: 1

Michael S.
Michael S.

Reputation: 701

I solved it myself. The reason for the long wait was that the value we were looking for did not exist, so the test failed. I can set the length in the cypress.json file:

{
  "defaultCommandTimeout": 60000,
  "responseTimeout": 30000,
  "requestTimeout": 30000
}

Upvotes: 1

Related Questions