From dd40782166f95b5179b67cf8d0aa814e519616fd Mon Sep 17 00:00:00 2001 From: Rafael Oleza Date: Thu, 6 Jun 2019 16:48:11 +0200 Subject: [PATCH] add delay to watch-path tests to make them less flaky --- spec/path-watcher-spec.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/path-watcher-spec.js b/spec/path-watcher-spec.js index a2a9a4e6d..5f97338b1 100644 --- a/spec/path-watcher-spec.js +++ b/spec/path-watcher-spec.js @@ -7,6 +7,7 @@ import { promisify } from 'util'; import { CompositeDisposable } from 'event-kit'; import { watchPath, stopAllWatchers } from '../src/path-watcher'; +import { timeoutPromise } from './async-spec-helpers'; temp.track(); @@ -21,6 +22,7 @@ describe('watchPath', function() { let subs; beforeEach(function() { + jasmine.useRealClock(); subs = new CompositeDisposable(); }); @@ -109,6 +111,12 @@ describe('watchPath', function() { waitForChanges(rootWatcher, subFile), waitForChanges(childWatcher, subFile) ]); + + // In Windows64, in some situations nsfw (the currently default watcher) + // does not trigger the change events if they happen just after start watching, + // so we need to wait some time. More info: https://github.com/atom/atom/issues/19442 + await timeoutPromise(300); + await writeFile(subFile, 'subfile\n', { encoding: 'utf8' }); await firstChanges; @@ -156,6 +164,11 @@ describe('watchPath', function() { expect(subWatcher0.native).toBe(parentWatcher.native); expect(subWatcher1.native).toBe(parentWatcher.native); + // In Windows64, in some situations nsfw (the currently default watcher) + // does not trigger the change events if they happen just after start watching, + // so we need to wait some time. More info: https://github.com/atom/atom/issues/19442 + await timeoutPromise(300); + // Ensure events are filtered correctly await Promise.all([ appendFile(rootFile, 'change\n', { encoding: 'utf8' }),