https://cypress.io logo
To ensure that you will read the correct sms, you ...
# e2e-testing
m
To ensure that you will read the correct sms, you have to delete all messages for the phone number in test. retrieve messages :
Copy code
cy.request({
    method: 'GET',
    url: `https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Messages.json?PageSize=${MESSAGES_LIMIT}&To=${phoneNumber}`,
    auth: {
      username: accountSid,
      password: authToken,
    }
  })
and for each of them delete:
Copy code
cy.request({
          method: 'DELETE',
          url: `https://api.twilio.com/2010-04-01/Accounts/${accountSid}/Messages/${message.sid}.json`,
          auth: {
            username: accountSid,
            password: authToken,
          }
  });
and then wait for a new incoming message