E2E transporter testing: checking email after creating an account

So, I am writing several E2E tests to create an account on a website. After creating a website account, the website will send me an email to verify my account so that I can log in. My question is, how far can the E2E test go? if I use the wrong path, if I use the protractor to go to Google, find the letter and click the link to check myself. Then return to the site and log in? My other possible option would be to somehow get my user ID and then send a request for verification?

I'm just not sure which direction would be better. Any ideas?

+5
source share
2 answers

You can pretty much say how far your tests should go. But if it is critical to send information by email, you should consider extracting this information during a test run.

In other words, this is the so-called β€œend-to-end testing,” but both ends may be outside the boundaries that we are used to thinking and considering.

Here is a solution using the mail-listener2 nodejs library , which worked for me during the test of the two-factor verification functionality (the registration code is sent by email after the username / password verification step is transmitted).

+2
source

Personally, I verify that the verification email is sent with the correct content. However, I cannot log in to Google to find the email. Instead, I found a server-side function that returns the last email sent to a specific email address. Here is how I use it:

 b.get(origin + '/-/e2e/last-email-sent?to=' + address, (response) => { var responseObj = JSON.parse(response.body); // Now I have the email text in responseObj.bodyHtmlText. // Let extract the URL to the next page: // (it the first thing we find that starts with our server origin, ie // http://whatever/....) var regexString = originRegexEscaped + '\\/[^"]+'; var matches = responseObj.bodyHtmlText.match(new RegExp(regexString)); if (!matches) { b.assert.fail(responseObj.bodyHtmlText, regexString, 'No next-page-link regex match in email'); } else { // Tell our e2e browser to go to the page linked in the email // as if the user had clicked the link in the email. b.url(matches[0]); } }); 

I am going to add many other related functions of the e2e test server, for example /-/e2e/fast-forward-time?how-much=3600-seconds : -)

What I do with a real Gmail user (a real Gmail account that I created for e2e tests and nothing more) is just registering. That is what OpenAuth works. If this works, I’m going to assume that any Gmail user will be able to read emails afterwards.

+1
source

Source: https://habr.com/ru/post/1213751/


All Articles