MCPcopy Index your code
hub / github.com/nodejs/node / test

Function test

test/parallel/test-fs-promises-watch.js:52–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50
51 let interval;
52 async function test() {
53 if (common.isMacOS) {
54 // On macOS delay watcher start to avoid leaking previous events.
55 // Refs: https://github.com/libuv/libuv/pull/4503
56 await setTimeout(common.platformTimeout(100));
57 }
58
59 const watcher = watch(testCase[testCase.field]);
60 for await (const { eventType, filename } of watcher) {
61 clearInterval(interval);
62 assert.strictEqual(['rename', 'change'].includes(eventType), true);
63 assert.strictEqual(filename, testCase.fileName);
64 break;
65 }
66
67 // Waiting on it again is a non-op
68 // eslint-disable-next-line no-unused-vars
69 for await (const p of watcher) {
70 assert.fail('should not run');
71 }
72 }
73
74 // Long content so it's actually flushed. toUpperCase so there's real change.
75 const content2 = Date.now() + testCase.fileName.toUpperCase().repeat(1e4);

Callers 1

Calls 5

clearIntervalFunction · 0.85
includesMethod · 0.80
setTimeoutFunction · 0.50
watchFunction · 0.50
failMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…