On 17/12/2013 14:06, Dale Harvey wrote:
Investigating some unit test failures I am seeing a lot of setTimeout's
located inside the tests

Yuck! No wonder we had intermittent issues.

just a reminder for coders and
more specifically reviewers that setTimeouts should pretty much only be
used to yield / spin the event loop inside tests, not for any form of timer
/ waiting solution

And also if you have something that's timer-based you can reliably test it by faking timers:

http://sinonjs.org/docs/#clock
http://cjohansen.no/en/javascript/faking_timers_and_dates_with_sinon

For example I've used them extensively in the dialer unit-tests to check dial-tone durations which were setTimeout()-based.

 Gabriele
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to