I wrote a function that's counting back with setInterval and I would like to test that it does work.
const countdown = setTimeout(() => countDownFunction(60), 1000)
expect(countdown).toBe(59)
The problem is that it's not deterministic and sometimes it might return 58 or 60, depending on where it's running (e.g. CI pipeline).
What are the best practices to test timeouts?
Aucun commentaire:
Enregistrer un commentaire