0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 07:27:22 +01:00
nodejs/test/sequential/test-timers-block-eventloop.js
Anatoli Papirovski 6963a93d0e
test: fix flaky timers-block-eventloop test
Due to extensive reliance on timings and the fs module, this test
is currently inherently flaky. Refactor it to simply use setImmediate
and only one busy loop.

PR-URL: https://github.com/nodejs/node/pull/18567
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-02-08 15:33:02 -05:00

19 lines
337 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
let called = false;
const t1 = setInterval(() => {
assert(!called);
called = true;
setImmediate(common.mustCall(() => {
clearInterval(t1);
clearInterval(t2);
}));
}, 10);
const t2 = setInterval(() => {
common.busyLoop(20);
}, 10);