Cypress · Senior · Question 67 of 76
How should Cypress tests handle randomness in the app, like shuffled lists?
- 1Seed or stub the randomness for stable output
- 2Run the test again until it happens to pass
- 3Avoid testing any random features
Show the answer
Correct answer: Seed or stub the randomness for stable output
Explanation
Stub Math.random in onBeforeLoad or set a seed via config to make tests repeatable.