So I am writing some E2E tests for creating an account on a website. After creating a website account, the website will send me an email to verify my account so I can login. My question is, how far is E2E testing suppose to go? would I be going in the wrong direction if I use protractor to go to google, find the email, and click the link to verify myself. Then go back to the website and login? My other possible option would be to somehow get my userID and then send a request for verification?
I'm just not sure which direction would be best. Any ideas?
It is pretty much arguable how far your tests should go. But if there is a critical to testing information being sent on email, you should consider extracting that information during the test run.
In other words, this is so called "end-to-end testing", but both of the ends could be beyond the borders we are used to think and consider.
Here is the solution using mail-listener2
nodejs library that worked for me during the Two Factor Authentication functionality test (registration code is sent to an email after passing username/password verification step).
Personally I do test that a verification email gets sent with the correct contents — I do not, however, login at Google, to find the email. Instead I've exposed a server side function that returns the latest email it sent to a certain email address. Here's 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's extract the URL to the next page:
// (it's the first thing we find that starts with our server origin, i.e.
// 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'm going to add lots of other funny e2e test server side functions too, like /-/e2e/fast-forward-time?how-much=3600-seconds
:-)
What I do test, with a real Gmail user (a real Gmail account I created for e2e tests and nothing else), is just signups. I.e. that OpenAuth login works. If that works, I'm going to assume any Gmail user is thereafter able to read emails.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With