From 187ff2b0ec884c28368d9dd481b4091bcfa5b12d Mon Sep 17 00:00:00 2001 From: Artem Kobzar Date: Wed, 24 Apr 2019 17:47:02 +0300 Subject: [PATCH] test: Trying to fix blinked tests for Travis CI. (#825) * test: Trying to fix blinked tests for Travis CI. * test: Move file path up for Windows in Travis CI. --- test.js | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/test.js b/test.js index bba4d59e..4a1ec36a 100644 --- a/test.js +++ b/test.js @@ -169,9 +169,8 @@ const runTests = function(baseopts) { watcher.on('add', (path) => { spy(path); }); - await waitForWatcher(watcher); - await delay(); + await waitForWatcher(watcher); (async () => { for (let path of paths.slice(0, 5)) { @@ -184,6 +183,7 @@ const runTests = function(baseopts) { delay(); })(); + await waitFor([[spy, 4]]); await waitFor([[spy, 9]]); paths.forEach(path => { spy.should.have.been.calledWith(path); @@ -278,6 +278,8 @@ const runTests = function(baseopts) { await write(testg1Path, Date.now()); await write(testh1Path, Date.now()); await write(testi1Path, Date.now()); + await waitFor([[spy, 11]]); + await waitFor([[spy, 22]]); await waitFor([[spy, 33]]); spy.should.have.been.calledWith(test1Path); @@ -757,25 +759,31 @@ const runTests = function(baseopts) { }); it('should traverse subdirs to match globstar patterns', async () => { const watchPath = getGlobPath('../../test-*/' + subdirId + '/**/a*.txt'); - fs.mkdirSync(getFixturePath('subdir'), PERM_ARR); - fs.mkdirSync(getFixturePath('subdir/subsub'), PERM_ARR); - fs.writeFileSync(getFixturePath('subdir/a.txt'), 'b'); - fs.writeFileSync(getFixturePath('subdir/b.txt'), 'b'); - fs.writeFileSync(getFixturePath('subdir/subsub/ab.txt'), 'b'); + const addFile = getFixturePath('add.txt'); + const subdir = getFixturePath('subdir'); + const subsubdir = getFixturePath('subdir/subsub'); + const aFile = getFixturePath('subdir/a.txt'); + const bFile = getFixturePath('subdir/b.txt'); + const subFile = getFixturePath('subdir/subsub/ab.txt'); + fs.mkdirSync(subdir, PERM_ARR); + fs.mkdirSync(subsubdir, PERM_ARR); + fs.writeFileSync(aFile, 'b'); + fs.writeFileSync(bFile, 'b'); + fs.writeFileSync(subFile, 'b'); await delay(); let watcher = chokidar_watch(watchPath, options); const spy = await aspy(watcher, 'all'); setTimeout(async () => { - await write(getFixturePath('add.txt'), Date.now()); - await write(getFixturePath('subdir/subsub/ab.txt'), Date.now()); - await fs_unlink(getFixturePath('subdir/a.txt')); - await fs_unlink(getFixturePath('subdir/b.txt')); + await write(addFile, Date.now()); + await write(subFile, Date.now()); + await fs_unlink(aFile); + await fs_unlink(bFile); }, 50); await waitFor([[spy.withArgs('add'), 3], spy.withArgs('unlink'), spy.withArgs('change')]); spy.withArgs('add').should.have.been.calledThrice; - spy.should.have.been.calledWith('unlink', getFixturePath('subdir/a.txt')); - spy.should.have.been.calledWith('change', getFixturePath('subdir/subsub/ab.txt')); + spy.should.have.been.calledWith('unlink', aFile); + spy.should.have.been.calledWith('change', subFile); spy.withArgs('unlink').should.have.been.calledOnce; spy.withArgs('change').should.have.been.calledOnce; }); @@ -831,8 +839,8 @@ const runTests = function(baseopts) { spy.should.have.been.calledWith('add', changePath); spy.should.have.been.calledOnce; - await delay(); await write(changePath, Date.now()); + await delay(); await waitFor([[spy, 2]]); spy.should.have.been.calledWith('change', changePath); spy.should.have.been.calledTwice;