add delay to watch-path tests to make them less flaky

This commit is contained in:
Rafael Oleza 2019-06-06 16:48:11 +02:00
parent 33f2bd37ee
commit dd40782166

View File

@ -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' }),