Uma forma diferente, mas valida também.
// Arquivo alurapic.cy.js
const usuarios = require('../../fixtures/usuarios.json');
usuarios.forEach(usuarios => {
it.only(`Cadastrar novo usuario ${usuarios.userName} ` , () => {
cy.register( usuarios.email, usuarios.fullName, usuarios.userName, usuarios.password)
})
});
//Arquivo gui.commands.js
Cypress.Commands.add('register', (email, fullName, userName, password) => {
cy.get('p > a').click();
cy.get('input[formcontrolname="email"]').type(email);
cy.get('input[formcontrolname="fullName"]').type(fullName);
cy.get('input[formcontrolname="userName"]').type(userName);
cy.get('input[formcontrolname="password"]').type(password);
cy.get('.btn').click();
})
//Arquivo usuarios.json
[
{
"email": "Iron-man@avengers.com",
"fullName": "Robert Downey Jr",
"userName": "ironman",
"password": "Playboyzinho"
},
{
"email": "Thor@avengers.com",
"fullName": "Chris Hemsworth",
"userName": "thor",
"password": "deusDoTrovão"
},
{
"email": "Hulk@avengers.com",
"fullName": "Mark Ruffalo",
"userName": "hulk",
"password": "hulkEsmaga"
}
]