Skip to content

Commit

Permalink
watcher - harden test for unexpected events
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Nov 11, 2021
1 parent 9efa55c commit 84c9bf4
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,27 @@ flakySuite('Recursive Watcher (parcel)', () => {
await Promises.writeFile(copiedFilepath, 'Hello Change');
await changeFuture;

// Create new file
const anotherNewFilePath = join(testDir, 'deep', 'anotherNewFile.txt');
changeFuture = awaitEvent(service, anotherNewFilePath, FileChangeType.ADDED);
await Promises.writeFile(anotherNewFilePath, 'Hello Another World');
await changeFuture;

await timeout(1500); // ensure the previous added event is flushed by now (can happen on macOS with fsevents)

// Read file does not emit event
changeFuture = awaitEvent(service, copiedFilepath, FileChangeType.UPDATED, 'unexpected-event-from-read-file');
await Promises.readFile(copiedFilepath);
changeFuture = awaitEvent(service, anotherNewFilePath, FileChangeType.UPDATED, 'unexpected-event-from-read-file');
await Promises.readFile(anotherNewFilePath);
await Promise.race([timeout(100), changeFuture]);

// Stat file does not emit event
changeFuture = awaitEvent(service, copiedFilepath, FileChangeType.UPDATED, 'unexpected-event-from-stat');
await Promises.stat(copiedFilepath);
changeFuture = awaitEvent(service, anotherNewFilePath, FileChangeType.UPDATED, 'unexpected-event-from-stat');
await Promises.stat(anotherNewFilePath);
await Promise.race([timeout(100), changeFuture]);

// Stat folder does not emit event
changeFuture = awaitEvent(service, copiedFolderpath, FileChangeType.UPDATED, 'unexpected-event-from-stat');
await Promises.stat(copiedFolderpath);
await Promise.race([timeout(100), changeFuture]);

// Delete file
Expand Down

0 comments on commit 84c9bf4

Please sign in to comment.