I have a test where I need to test a confirmation link in an email being sent.
Im at a point where I am catching the email and getting the link, but when I then try to visit that link I am getting an error link not defined
it("I fill out the form", () => {
cy.visit(Cypress.env("gettingStartedUrl"))
cy.getElementById('firstName').click().type("Test")
cy.getElementById('lastName').click().type("Test")
cy.contains("Next").click()
})
it("I get the link from the confirmation email", () => {
cy.mailosaurGetMessage(serverId, {
sentTo: emailAddress
}).then(email => {
expect(email.subject).to.equal('Welcome to Dashboard')
confirmationLink = email.text.links[1].href;
})
})
it('Visits the login link', () => {
// This is where I get confirmationLink not defined
cy.visit(confirmationLink)
})
There is a second in the test runner that I can see it is trying to redirect to the right link, but then the test runner freezes up and I get the confirmationLink is not defined