我目前正在设置一个允许我创建随机电子邮件的测试场景,并且我想做更多系列的测试并继续写入同一个 JSON 文件,而不是覆盖我已经发送到 JSON 文件的内容。这意味着我想使用相同的 JSON 文件来保存我在测试中创建的所有电子邮件。
有谁知道更好的方法来做到这一点?
Cypress.Commands.add("form", ()=> {
// fill-out form
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
const fullName = 'MockaData Testing'
const email = makeid(6) + "@aharo.com";
console.log(makeid(5));
cy.get('#full_name')
.type(fullName)
cy.get('#company')
.type('Testing')
cy.get('#phone_number')
.type('2022569878')
cy.get('#email')
.type(email).writeFile('cypress/fixtures/users.json', {name: fullName, email: email})
cy.get('#password')
.type('Abcd1234')
// click submit
cy.get(".app-submit-btn-text", { multiple: true }).click()
})