Skip to content

Instantly share code, notes, and snippets.

@sergtimosh
Last active April 26, 2020 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergtimosh/09bc62bd64858ca7a93af5d9c491829b to your computer and use it in GitHub Desktop.
Save sergtimosh/09bc62bd64858ca7a93af5d9c491829b to your computer and use it in GitHub Desktop.
#test scenario
describe('Order Confirmation', () => {
test('Send Email Order Confirmation', async () => {
const testId = new Date().getTime()
const message = `Test Email Message ${randNum}: ${faker.random.words(20)}`
const subject = `Test Email Message Subject ${randNum}: ${faker.random.words(3)}`
//Create Order and send mail steps...
//verify mailBox for new mail within some period of time
let emails = await mailHelper.messageChecker()
let startTime = Date.now()
while (emails.length === 0 && Date.now() - startTime < 20000) {
console.log(`Polling mail from: ${userEmail}...`)
await page.waitFor(5000)
emails = await mailHelper.messageChecker()
console.log(emails)
}
expect(emails.length).toBeGreaterThanOrEqual(1) //ensure new mail arrived
expect(emails[0].subject).toContain(subject.substr(0, 50)) //assert subject
const emailBodyHtml = emails[0].body.html //get body
const actualMessage = mailHelper.getBodyText(emailBodyHtml) //get text from body
expect(actualMessage.trim()).toBe(message) //assert body text
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment