Skip to content

Commit

Permalink
Merge pull request #74 from parcel-bundler/fix-tests
Browse files Browse the repository at this point in the history
Improve flakey tests
  • Loading branch information
devongovett committed Dec 7, 2017
2 parents 7dde0d7 + 0213fe2 commit 916d939
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 5 deletions.
7 changes: 6 additions & 1 deletion packages/core/parcel/src/Bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
1 change: 0 additions & 1 deletion packages/core/parcel/test/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
1 change: 1 addition & 0 deletions packages/core/parcel/test/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--timeout 15000
1 change: 0 additions & 1 deletion packages/core/parcel/test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion packages/core/parcel/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/parcel/test/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 916d939

Please sign in to comment.