magnificent-lamp-44201
03/16/2023, 6:08 AMexample.cy.js
javascript
describe('Sign up', () => {
const password = "test-password";
let inboxId;
let emailAddress;
let link;
it('sample', () => {
cy.visit('http://localhost:3000/');
cy.get('h2').contains('Iniciar');
cy.wait(5000);
cy.get('a').contains('Don\'t').click(); cy.get('label[for="password"]').contains('Create a Password');
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;
// sign up with inbox email address and the password
cy.get('input[name="email"]').type(emailAddress);
cy.get('input[name="password"]').type(password);
cy.get('button[type="submit"]').contains('Sign up').click();
cy.waitForLatestEmail(inboxId).then(email => {
// verify we received an email
assert.isDefined(email);
console.log("print the body")
console.log(email.body)
// extract the link
link = /<a\s+(?:[^>]*?\s+)?href=(["'])(.*?)\1/.exec(email.body)[2];
console.log(link)
});
});
});
it('should works', () => {
console.log('Print the URL: ' + link)
cy.visit(link);
});
it('should works', () => {
// it displays the link sent through email, but when I visit it throws an error
// see image attached
console.log('Print the URL: ' + link)
cy.visit(link);
});magnificent-lamp-44201
03/16/2023, 6:08 AMcommands.js
javascript
//<gen>cypress_client_add_command
const { MailSlurp } = require('mailslurp-client');
// set your api key with an environment variable `CYPRESS_API_KEY` or configure using `env` property in config file
// (cypress prefixes environment variables with CYPRESS)
const apiKey = Cypress.env('API_KEY')
const mailslurp = new MailSlurp({ apiKey });
Cypress.Commands.add("createInbox", () => {
return mailslurp.createInbox();
});
Cypress.Commands.add("waitForLatestEmail", (inboxId) => {
// how long we should hold connection waiting for an email to arrive
const timeoutMillis = 30_000;
return mailslurp.waitForLatestEmail(inboxId, timeoutMillis)
});
//</gen>magnificent-lamp-44201
03/16/2023, 6:09 AMhttp://localhost:3000/#error=invalid_request&error_code=400&error_description=Verify+requires+a+verification+type.
I noticed that the only way to access the system through the link is by clicking it directly through the email (once it's clicked, the user can see the home page).
I'll appreciate any help you can provide me to solve my issue (: