I am trying to write an end-to-end test using Cypress and mailslurp. I can retrieve activation URL from the onboarding email and have stored the value in a variable called verificationLink. Now that I have the URL, I want to use it in cy.visit(URL) but I don't know how to get the stored value out of the verificationLink.
I know the following code is incorrect, but it gives you the idea of what I am trying to do.
cy.waitForLatestEmail('inbox.id').then(email => {
console.log(email)
const verificationLink = /my-regex-code-to-get-the-link,e.g. \/([0-9]{6})$\//.exec(email.body);
console.log(verificationLink)
cy.visit(verificationLink)
})
I have tried to follow the instructions/advice from the links below but with no success. Does anyone know how to do this?
https://docs.cypress.io/guides/core-concepts/variables-and-aliases.html#Closures