In cypress you can add this function as custom commands in support/commands.js
file:
Cypress.Commands.add("randomValueFromArray", (array) => { return array[Math.floor(Math.random() * array.length)]; })
& Use it the spec make sure to add import './commands'
in support/index.js
cy.randomValueFromArray([1,2,5,6,3,8,9,2,5,7]).then((value) => {
cy.log('VALUE', value);
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…