diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-04-21 14:06:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-21 14:06:57 -0400 |
commit | 8ba6e4fa137059a77ceed88de937bbb6c5276c45 (patch) | |
tree | 4169fe3ce3b86a85006627cecd95655c127d1ddb /js | |
parent | 961f87e1c5d0cbe312a02997123e65fc315afb06 (diff) |
Fix flaky tests (#2164)
Diffstat (limited to 'js')
-rw-r--r-- | js/timers_test.ts | 16 |
1 files 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() { |