タイマーモック · Jest

The native timer functions (i.e., setTimeout(), setInterval(), clearTimeout(), clearInterval()) are less than ideal for a testing environment since they depend on real time to elapse. Jest は タイマー関数を自分で時間経過をコントロールできる関数に置き換えることができます。 Great Scott!