I was trying to extract a link to proceed with user registration using Cypress and Mailslurp. For that, I wrote the following code:
let inboxId;
let emailAddress;
describe('sign up', () => {
beforeEach(() => {
cy.viewport(1920, 1080);
})
it('receive sign up link', () => {
cy.visit('/signup');
cy.createInbox().then(inbox => {
// verify a new inbox was created
assert.isDefined(inbox)
// save the inboxId for later checking the emails
inboxId = inbox.id
emailAddress = inbox.emailAddress;
cy.get('#email-input').type(emailAddress);
cy.get('.bg-gray-100 > .p-button').click();
})
})
it('extract the confirmation link and extract the code', () => {
cy.waitForLatestEmail(inboxId).then(email => {
const emailHTML = email.body;
const regexLink = /<a href="([^"]+)">/;
const match = emailHTML.match(regexLink);
const link = match[0];
cy.visit(link);
});
});
})
But the constant 'const link' returns a null value
I was expecting to receive the link to continue the register link