rmurphey / js-assessment

A test-driven approach to assessing JS skills
5.15k stars 2.05k forks source link

Make count.js test less brittle #114

Closed e0da closed 9 years ago

e0da commented 9 years ago

If you set your interval to 100 as the problem prompts, then at exactly 200, it's very likely that you will still have exactly 1 item in nums when the expectation is evaluated. Bump the test timeout to 250, and the behavior is much more deterministic.

jamesplease commented 9 years ago

Thanks for the PR, @justinforce! I'll take a closer look at this sometime soon, but I figured I'd leave a note for myself (or anyone else) here: these sorts of tests are exactly what sinon's fake timer is perfect at simulating.

jamesplease commented 9 years ago

@justinforce, do you think that #119 does a more precise job at being deterministic about this? It's overriding the browser's internal timer to be exact in its counting.

ashleygwilliams commented 9 years ago

closing thing in favor of #119