✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Hier die app.js:
const random = Math.random() * 100 // random ms of time
const btn = document.createElement('button')
document.body.appendChild(btn)
setTimeout(() => {
// add the class active after a random amount of time
btn.setAttribute('class', 'active')
}, random)
und der dazugehörige Test in der test.cs.js:
it('does something different based on the class of the button', () => {
// RERUN THIS TEST OVER AND OVER AGAIN
// AND IT WILL SOMETIMES BE TRUE, AND
// SOMETIMES BE FALSE.
cy.get('button').then(($btn) => {
if ($btn.hasClass('active')) {
// do something if it's active
} else {
// do something else
}
})
})
Ist dieser Test deterministisch?