node/test/sequential/test-timers-block-eventloop.js
Anatoli Papirovski ab8edc9d48 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-04-13 03:40:29 +01: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);