I am using javascript to create automated testing for a B2C sign-up policy. I am using mailosaur as an inbox to receive my verification code to complete the email registration. My script is similar to the below-pasted script. This can help me validate the message that's been successfully sent to the inbox however, I would want to add an additional fixture where the script can copy just the verification code (The body of the message would look like "your code is: XXXXXX") sent to the generic inbox and paste it back to a registration page to complete the user registration. Please advise how can this be achieved? Many Thanks
import uuidv4 from "uuid/v4";
import MailosaurClient from "mailosaur";
import signUpModel from "./page_models/sign_up_model";
const client = new MailosaurClient("<MAILOSAUR API KEY>");
const mailosaurServerId = "<MAILOSAUR SERVER ID>";
const emailAddress = `${uuidv4()}@dev-tester.com`;
fixture("Airport Gap Signup Flow")
.page("https://airportgap-staging.dev-tester.com/tokens/new")
.beforeEach(async () => await client.messages.deleteAll(mailosaurServerId));
test("User receives an email after signup", async t => {
await t
.typeText(signUpModel.emailInput, emailAddress)
.typeText(signUpModel.passwordInput, "airportgap123")
.click(signUpModel.submitButton);
await t.wait(10000);
let message = await client.messages.get(mailosaurServerId, {
sentTo: emailAddress
});
await t.expect(message.to[0].email).eql(emailAddress);
await t.expect(message.subject).eql("Here's your generated token");
await t
.expect(message.html.body)
.contains("Here's your newly generated Airport Gap token");
});
Aucun commentaire:
Enregistrer un commentaire