diff --git a/src/Bundler.js b/src/Bundler.js index a6c12cd4865..a65dad44318 100644 --- a/src/Bundler.js +++ b/src/Bundler.js @@ -153,7 +153,12 @@ class Bundler extends EventEmitter { this.farm = WorkerFarm.getShared(this.options); if (this.options.watch) { - this.watcher = new FSWatcher; + // FS events on macOS are flakey in the tests, which write lots of files very quickly + // See https://github.com/paulmillr/chokidar/issues/612 + this.watcher = new FSWatcher({ + useFsEvents: process.env.NODE_ENV !== 'test' + }); + this.watcher.on('change', this.onChange.bind(this)); } diff --git a/test/css.js b/test/css.js index 59dc89b5f59..6286d937a2b 100644 --- a/test/css.js +++ b/test/css.js @@ -4,7 +4,6 @@ const {bundle, run, assertBundleTree} = require('./utils'); describe('css', function () { it('should produce two bundles when importing a CSS file', async function () { - this.timeout(5000); let b = await bundle(__dirname + '/integration/css/index.js'); assertBundleTree(b, { diff --git a/test/mocha.opts b/test/mocha.opts new file mode 100644 index 00000000000..22e7a85ec5a --- /dev/null +++ b/test/mocha.opts @@ -0,0 +1 @@ +--timeout 15000 \ No newline at end of file diff --git a/test/server.js b/test/server.js index fe5bbc134fa..6721568d409 100644 --- a/test/server.js +++ b/test/server.js @@ -38,7 +38,6 @@ describe('server', function () { }); it('should serve a default page if the main bundle is an HTML asset', async function () { - this.timeout(5000); let b = bundler(__dirname + '/integration/html/index.html'); server = b.serve(0); diff --git a/test/utils.js b/test/utils.js index f29605108ed..d1d45e9dcbe 100644 --- a/test/utils.js +++ b/test/utils.js @@ -72,7 +72,7 @@ function assertBundleTree(bundle, tree) { } if (tree.childBundles) { - let children = Array.from(bundle.childBundles);//.sort((a, b) => a.name - b.name); + let children = Array.from(bundle.childBundles).sort((a, b) => Array.from(a.assets).sort()[0].basename < Array.from(b.assets).sort()[0].basename ? -1 : 1); assert.equal(bundle.childBundles.size, tree.childBundles.length); tree.childBundles.forEach((b, i) => assertBundleTree(children[i], b)); } diff --git a/test/watcher.js b/test/watcher.js index 604278f51a0..bf141f8e739 100644 --- a/test/watcher.js +++ b/test/watcher.js @@ -91,7 +91,7 @@ describe('watcher', function () { let bundle = await b.bundle(); let mtimes = fs.readdirSync(__dirname + '/dist').map(f => fs.statSync(__dirname + '/dist/' + f).mtime.getTime() / 1000 | 0); - await sleep(500); // mtime only has second level precision + await sleep(1000); // mtime only has second level precision fs.writeFileSync(__dirname + '/input/b.js', 'module.exports = require("./common")'); bundle = await nextBundle(b);