From 8ba6e4fa137059a77ceed88de937bbb6c5276c45 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 21 Apr 2019 14:06:57 -0400 Subject: Fix flaky tests (#2164) --- js/timers_test.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/js/timers_test.ts b/js/timers_test.ts index b43817437..51dfbd7e0 100644 --- a/js/timers_test.ts +++ b/js/timers_test.ts @@ -58,10 +58,9 @@ test(async function timeoutCancelSuccess() { let count = 0; const id = setTimeout(() => { count++; - }, 500); + }, 1); // Cancelled, count should not increment clearTimeout(id); - // Wait a bit longer than 500ms await waitForMs(600); assertEquals(count, 0); }); @@ -113,19 +112,14 @@ test(async function intervalSuccess() { let count = 0; const id = setInterval(() => { count++; - if (count === 2) { - // TODO: clearInterval(id) here alone seems not working - // causing unit_tests.ts to block forever - // Requires further investigation... - clearInterval(id); - resolve(); - } - }, 200); + clearInterval(id); + resolve(); + }, 100); await promise; // Clear interval clearInterval(id); // count should increment twice - assertEquals(count, 2); + assertEquals(count, 1); }); test(async function intervalCancelSuccess() { -- cgit v1.2.3