Skip to content

Commit

Permalink
Fix flaky tests (#2164)
Browse files Browse the repository at this point in the history
  • Loading branch information
ry authored Apr 21, 2019
1 parent 961f87e commit 8ba6e4f
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions js/timers_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 8ba6e4f

Please sign in to comment.