Skip to content

Commit 187ff2b

Browse files
JSMonkpaulmillr
authored andcommitted
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.
1 parent db99076 commit 187ff2b

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

test.js

+22-14
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,8 @@ const runTests = function(baseopts) {
169169
watcher.on('add', (path) => {
170170
spy(path);
171171
});
172-
await waitForWatcher(watcher);
173172

174-
await delay();
173+
await waitForWatcher(watcher);
175174

176175
(async () => {
177176
for (let path of paths.slice(0, 5)) {
@@ -184,6 +183,7 @@ const runTests = function(baseopts) {
184183
delay();
185184
})();
186185

186+
await waitFor([[spy, 4]]);
187187
await waitFor([[spy, 9]]);
188188
paths.forEach(path => {
189189
spy.should.have.been.calledWith(path);
@@ -278,6 +278,8 @@ const runTests = function(baseopts) {
278278
await write(testg1Path, Date.now());
279279
await write(testh1Path, Date.now());
280280
await write(testi1Path, Date.now());
281+
await waitFor([[spy, 11]]);
282+
await waitFor([[spy, 22]]);
281283
await waitFor([[spy, 33]]);
282284

283285
spy.should.have.been.calledWith(test1Path);
@@ -757,25 +759,31 @@ const runTests = function(baseopts) {
757759
});
758760
it('should traverse subdirs to match globstar patterns', async () => {
759761
const watchPath = getGlobPath('../../test-*/' + subdirId + '/**/a*.txt');
760-
fs.mkdirSync(getFixturePath('subdir'), PERM_ARR);
761-
fs.mkdirSync(getFixturePath('subdir/subsub'), PERM_ARR);
762-
fs.writeFileSync(getFixturePath('subdir/a.txt'), 'b');
763-
fs.writeFileSync(getFixturePath('subdir/b.txt'), 'b');
764-
fs.writeFileSync(getFixturePath('subdir/subsub/ab.txt'), 'b');
762+
const addFile = getFixturePath('add.txt');
763+
const subdir = getFixturePath('subdir');
764+
const subsubdir = getFixturePath('subdir/subsub');
765+
const aFile = getFixturePath('subdir/a.txt');
766+
const bFile = getFixturePath('subdir/b.txt');
767+
const subFile = getFixturePath('subdir/subsub/ab.txt');
768+
fs.mkdirSync(subdir, PERM_ARR);
769+
fs.mkdirSync(subsubdir, PERM_ARR);
770+
fs.writeFileSync(aFile, 'b');
771+
fs.writeFileSync(bFile, 'b');
772+
fs.writeFileSync(subFile, 'b');
765773

766774
await delay();
767775
let watcher = chokidar_watch(watchPath, options);
768776
const spy = await aspy(watcher, 'all');
769777
setTimeout(async () => {
770-
await write(getFixturePath('add.txt'), Date.now());
771-
await write(getFixturePath('subdir/subsub/ab.txt'), Date.now());
772-
await fs_unlink(getFixturePath('subdir/a.txt'));
773-
await fs_unlink(getFixturePath('subdir/b.txt'));
778+
await write(addFile, Date.now());
779+
await write(subFile, Date.now());
780+
await fs_unlink(aFile);
781+
await fs_unlink(bFile);
774782
}, 50);
775783
await waitFor([[spy.withArgs('add'), 3], spy.withArgs('unlink'), spy.withArgs('change')]);
776784
spy.withArgs('add').should.have.been.calledThrice;
777-
spy.should.have.been.calledWith('unlink', getFixturePath('subdir/a.txt'));
778-
spy.should.have.been.calledWith('change', getFixturePath('subdir/subsub/ab.txt'));
785+
spy.should.have.been.calledWith('unlink', aFile);
786+
spy.should.have.been.calledWith('change', subFile);
779787
spy.withArgs('unlink').should.have.been.calledOnce;
780788
spy.withArgs('change').should.have.been.calledOnce;
781789
});
@@ -831,8 +839,8 @@ const runTests = function(baseopts) {
831839
spy.should.have.been.calledWith('add', changePath);
832840
spy.should.have.been.calledOnce;
833841

834-
await delay();
835842
await write(changePath, Date.now());
843+
await delay();
836844
await waitFor([[spy, 2]]);
837845
spy.should.have.been.calledWith('change', changePath);
838846
spy.should.have.been.calledTwice;

0 commit comments

Comments
 (0)