mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
Fix flaky tests (#2164)
This commit is contained in:
parent
961f87e1c5
commit
8ba6e4fa13
1 changed files with 5 additions and 11 deletions
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue