DEV Community

Discussion on: Math.random() in tests

Collapse
 
michalbryxi profile image
Michal Bryxí

Great question. I would say that you actually always want to have a pseudo-random seed (good trick is to pin it to pull-request branch name), because this gives you the ability to "shake the universe". Which turns out tend to uncover a lot of edge-cases your manual dice roll did not account for. On each run of the CI you are more and more sure that every possible input combination is taken care of without writing additional test code.

I would go as far as stating that an ember app (that's what I mostly work with) of any non-trivial size/complexity that does not use pseudo-random seed in the tests for running ember-exam has at least one hidden race condition.

I had few posts touching this topic (1), (2)