Skip to content

Commit

Permalink
Stabilize tests when running on Travis/darwin
Browse files Browse the repository at this point in the history
Running the tests and opening/closing watchers too quickly on
underpowered CI VMs causes problems.
  • Loading branch information
es128 committed Feb 19, 2017
1 parent b427e9c commit 3f7f113
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,16 @@ beforeEach(function() {
fixturesPath = getFixturePath('');
});

function closeWatchers() {
function closeWatchers(done) {
var u;
while (u = usedWatchers.pop()) u.close();
if (done) {
process.env.TRAVIS && os === 'darwin' ? setTimeout(done, 500) : done();
}
}
function disposeWatcher(watcher) {
if (!watcher || !watcher.close) return;
osXFsWatch ? usedWatchers.push(watcher) : watcher.close();
os === 'darwin' ? usedWatchers.push(watcher) : watcher.close();
}
afterEach(function() {
disposeWatcher(watcher);
Expand Down Expand Up @@ -172,7 +175,7 @@ function runTests(baseopts) {
waitFor([readySpy], function() {
readySpy.should.have.been.calledOnce;
rawSpy = undefined;
done()
closeWatchers(done);
});
});
it('should produce an instance of chokidar.FSWatcher', function() {
Expand Down

0 comments on commit 3f7f113

Please sign in to comment.