Last active
April 26, 2020 11:45
-
-
Save sergtimosh/09bc62bd64858ca7a93af5d9c491829b to your computer and use it in GitHub Desktop.
#test scenario
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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