Merge pull request #297 from strongloop/fix/ci

test: fix browserify-based tests
This commit is contained in:
Miroslav Bajtoš 2019-10-07 10:38:13 +02:00 committed by GitHub
commit 0bbe8335a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 0 deletions

View File

@ -8,6 +8,7 @@
var boot = require('../'); var boot = require('../');
var async = require('async'); var async = require('async');
var exportBrowserifyToFile = require('./helpers/browserify').exportToSandbox; var exportBrowserifyToFile = require('./helpers/browserify').exportToSandbox;
var packageFilter = require('./helpers/browserify').packageFilter;
var fs = require('fs'); var fs = require('fs');
var path = require('path'); var path = require('path');
var expect = require('chai').expect; var expect = require('chai').expect;
@ -66,6 +67,7 @@ function browserifyTestApps(apps, next) {
var b = browserify({ var b = browserify({
debug: true, debug: true,
basedir: path.resolve(__dirname, './fixtures'), basedir: path.resolve(__dirname, './fixtures'),
packageFilter,
}); });
var bundles = []; var bundles = [];

View File

@ -7,6 +7,7 @@
var boot = require('../'); var boot = require('../');
var exportBrowserifyToFile = require('./helpers/browserify').exportToSandbox; var exportBrowserifyToFile = require('./helpers/browserify').exportToSandbox;
var packageFilter = require('./helpers/browserify').packageFilter;
var fs = require('fs'); var fs = require('fs');
var path = require('path'); var path = require('path');
var expect = require('chai').expect; var expect = require('chai').expect;
@ -21,6 +22,7 @@ var compileStrategies = {
var b = browserify({ var b = browserify({
basedir: appDir, basedir: appDir,
debug: true, debug: true,
packageFilter,
}); });
b.require('./app.js', {expose: 'browser-app'}); b.require('./app.js', {expose: 'browser-app'});
return b; return b;
@ -31,6 +33,7 @@ var compileStrategies = {
basedir: appDir, basedir: appDir,
extensions: ['.coffee'], extensions: ['.coffee'],
debug: true, debug: true,
packageFilter,
}); });
b.transform('coffeeify'); b.transform('coffeeify');

View File

@ -21,3 +21,16 @@ function exportToSandbox(b, fileName, callback) {
}); });
} }
exports.exportToSandbox = exportToSandbox; exports.exportToSandbox = exportToSandbox;
exports.packageFilter = function packageFilter(pkg, dir) {
// async@3 (used e.g. by loopback-connector) is specifying custom
// browserify config, in particular it wants to apply transformation
// `babelify`. We don't have `babelify` installed because we are
// testing using latest Chrome and thus don't need any transpilation.
// Let's remove the browserify config from the package and force
// browserify to use our config instead.
if (pkg.name === 'async') {
delete pkg.browserify;
}
return pkg;
};