Skip to content

Commit

Permalink
test: Trying to fix blinked tests for Travis CI. (#825)
Browse files Browse the repository at this point in the history
* test: Trying to fix blinked tests for Travis CI.

* test: Move file path up for Windows in Travis CI.
  • Loading branch information
JSMonk authored and paulmillr committed Apr 24, 2019
1 parent db99076 commit 187ff2b
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions test.js
Expand Up @@ -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)) {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
});
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 187ff2b

Please sign in to comment.