Skip to content

Commit 2bff1af

Browse files
committed
test: clarify files watcher debounce timer interception
1 parent 6157d26 commit 2bff1af

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

test/parallel/test-watch-mode-files_watcher-clear.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ const timers = require('node:timers');
1313
const originalSetTimeout = timers.setTimeout;
1414
const originalClearTimeout = timers.clearTimeout;
1515
const { promise, resolve } = Promise.withResolvers();
16+
const debounce = 1000;
1617
let debounceTimer;
1718
let debounceTimerCallback;
1819
let debounceTimerCleared = false;
1920

2021
timers.setTimeout = function(fn, delay, ...args) {
21-
if (delay === 1000) {
22+
// Only intercept the FilesWatcher debounce timer configured below.
23+
if (delay === debounce) {
2224
const timer = {
2325
__proto__: null,
2426
ref() { return this; },
@@ -50,7 +52,7 @@ try {
5052
const file = tmpdir.resolve('watcher-clear.js');
5153
writeFileSync(file, '0');
5254

53-
const watcher = new FilesWatcher({ debounce: 1000, mode: 'all' });
55+
const watcher = new FilesWatcher({ debounce, mode: 'all' });
5456
watcher.on('changed', common.mustNotCall());
5557
watcher.watchPath(file, false);
5658

0 commit comments

Comments
 (0)