Skip to content

Commit 9e0965a

Browse files
JSMonkpaulmillr
authored andcommitted
Fix Windows tests in Travis CI (#832)
* test: Make big timeout to catch error inside Windows tests. * test: Write and unlink files in paralel mode. * test: Change order of asserts. * test: Change strategy of testing subdir global.
1 parent c95a98f commit 9e0965a

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

test.js

+20-15
Original file line numberDiff line numberDiff line change
@@ -774,18 +774,23 @@ const runTests = function(baseopts) {
774774
await delay();
775775
let watcher = chokidar_watch(watchPath, options);
776776
const spy = await aspy(watcher, 'all');
777-
setTimeout(async () => {
778-
await write(addFile, Date.now());
779-
await write(subFile, Date.now());
780-
await fs_unlink(aFile);
781-
await fs_unlink(bFile);
782-
}, 50);
783-
await waitFor([[spy.withArgs('add'), 3], spy.withArgs('unlink'), spy.withArgs('change')]);
784-
spy.withArgs('add').should.have.been.calledThrice;
785-
spy.should.have.been.calledWith('unlink', aFile);
777+
await Promise.all([
778+
write(addFile, Date.now()),
779+
write(subFile, Date.now()),
780+
fs_unlink(aFile),
781+
fs_unlink(bFile),
782+
]);
783+
784+
await waitFor([spy.withArgs('change')]);
785+
spy.withArgs('change').should.have.been.calledOnce;
786786
spy.should.have.been.calledWith('change', subFile);
787+
788+
await waitFor([spy.withArgs('unlink')]);
787789
spy.withArgs('unlink').should.have.been.calledOnce;
788-
spy.withArgs('change').should.have.been.calledOnce;
790+
spy.should.have.been.calledWith('unlink', aFile);
791+
792+
await waitFor([[spy.withArgs('add'), 3]]);
793+
spy.withArgs('add').should.have.been.calledThrice;
789794
});
790795
it('should resolve relative paths with glob patterns', async () => {
791796
const id = subdirId.toString();
@@ -798,10 +803,10 @@ const runTests = function(baseopts) {
798803
const spy = await aspy(watcher, 'all');
799804

800805
spy.should.have.been.calledWith('add');
801-
setTimeout(async () => {
802-
await write(addPath, Date.now());
803-
await write(changePath, Date.now());
804-
}, 50);
806+
await Promise.all([
807+
write(addPath, Date.now()),
808+
write(changePath, Date.now())
809+
]);
805810
await waitFor([[spy, 3], spy.withArgs('add', addPath)]);
806811
spy.should.have.been.calledWith('add', addPath);
807812
spy.should.have.been.calledWith('change', changePath);
@@ -2010,7 +2015,7 @@ const runTests = function(baseopts) {
20102015
};
20112016

20122017
describe('chokidar', function() {
2013-
this.timeout(6000);
2018+
this.timeout(60000);
20142019
before(async () => {
20152020
let created = 0;
20162021
await rimraf(FIXTURES_PATH);

0 commit comments

Comments
 (0)