\spec.js
it.only('Castro de novo usuário',()=>{
const newUser = {
'email' : "teste@alura.com.br",
'fullName' : "Novo Usuário",
'name' : "teste_alura",
'password' : "senha123"
}
cy.CreateUser(newUser);
cy.contains('button', 'login').should('be.visible');
cy.contains('h4','Login').should('be.visible');
});
\commands.js
Cypress.Commands.add('CreateUser', (user) =>{
cy.contains('a', 'Register now').click();
cy.get("input[formcontrolname='email']").type(user.email);
cy.get("input[formcontrolname='fullName']").type(user.fullName);
cy.get("input[formcontrolname='userName']").type(user.name);
cy.get("input[formcontrolname='password']").type(user.password);
cy.contains('button', 'Register').click();
})