Skip to content

Commit

Permalink
changed tests to use a production build rather than source
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Nov 21, 2021
1 parent 8bfaff0 commit 55feb89
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ docs
matter-doc-theme
build/matter-dev.js
build/matter-dev.min.js
build/matter.dev.js
build/matter.dev.min.js
demo/js/lib/matter-dev.js
demo/js/Examples.min.js
examples/build
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"serve": "webpack-dev-server --no-cache --mode development --config webpack.demo.config.js",
"watch": "nodemon --watch webpack.demo.config.js --exec \"npm run serve\"",
"build": "webpack --mode=production --no-hot --no-watch & webpack --mode=production --no-hot --no-watch --env.MINIMIZE",
"build-alpha": "webpack --mode=production --env.ALPHA & webpack --mode=production --env.MINIMIZE --env.ALPHA",
"build-alpha": "webpack --mode=production --no-hot --no-watch --env.KIND=alpha & webpack --mode=production --no-hot --no-watch --env.MINIMIZE --env.KIND=alpha",
"build-dev": "webpack --mode=production --no-hot --no-watch --env.KIND=dev & webpack --mode=production --no-hot --no-watch --env.MINIMIZE --env.KIND=dev",
"build-demo": "rm -rf ./demo/js && webpack --no-hot --no-watch --config webpack.demo.config.js --mode=production && webpack --no-hot --no-watch --config webpack.demo.config.js --mode=production --env.MINIMIZE",
"lint": "eslint 'src/**/*.js' 'demo/src/**/*.js' 'examples/*.js' 'webpack.*.js'",
"doc": "yuidoc --config yuidoc.json --project-version $npm_package_version",
Expand All @@ -53,7 +54,7 @@
"test-all": "jest --no-cache",
"test-save": "SAVE=true npm run test-node",
"test-watch": "npm run test-node -- --watch",
"test-node": "node --expose-gc node_modules/.bin/jest --no-cache --runInBand ./test/Examples.spec.js",
"test-node": "npm run build-dev && node --expose-gc node_modules/.bin/jest --no-cache --runInBand ./test/Examples.spec.js",
"test-browser": "node --expose-gc node_modules/.bin/jest --no-cache --runInBand ./test/Browser.spec.js",
"changelog": "conventional-changelog -i CHANGELOG.md -s -r",
"release": "npm version --no-git-tag-version",
Expand Down
2 changes: 1 addition & 1 deletion test/ExampleWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const reset = M => {

const mock = require('mock-require');
const { engineCapture } = require('./TestTools');
const MatterDev = stubBrowserFeatures(require('../src/module/main'));
const MatterDev = stubBrowserFeatures(require('../build/matter.dev'));
const MatterBuild = stubBrowserFeatures(require('../build/matter'));
const Example = require('../examples/index');

Expand Down
2 changes: 1 addition & 1 deletion test/TestTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ const logReport = (captures, version) => {
}
}

return `Output logs from ${color(version, colors.Yellow)} version on last run\n\n`
return `Output logs from ${color(version, colors.Yellow)} build on last run\n\n`
+ (report ? report : ' None\n');
};

Expand Down
9 changes: 4 additions & 5 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ const execSync = require('child_process').execSync;

module.exports = (env = {}) => {
const minimize = env.MINIMIZE || false;
const alpha = env.ALPHA || false;
const kind = env.KIND || null;
const sizeThreshold = minimize ? 100 * 1024 : 512 * 1024;

const commitHash = execSync('git rev-parse --short HEAD').toString().trim();
const version = !alpha ? pkg.version : `${pkg.version}-alpha+${commitHash}`;
const version = !kind ? pkg.version : `${pkg.version}-${kind}+${commitHash}`;
const license = fs.readFileSync('LICENSE', 'utf8');
const resolve = relativePath => path.resolve(__dirname, relativePath);

const alphaInfo = 'Experimental pre-release build.\n ';
const banner =
`${pkg.name} ${version} by @liabru
${alpha ? alphaInfo : ''}${pkg.homepage}
${kind ? 'Experimental pre-release build.\n ' : ''}${pkg.homepage}
License ${pkg.license}${!minimize ? '\n\n' + license : ''}`;

return {
Expand All @@ -32,7 +31,7 @@ License ${pkg.license}${!minimize ? '\n\n' + license : ''}`;
umdNamedDefine: true,
globalObject: 'this',
path: resolve('./build'),
filename: `[name]${alpha ? '.alpha' : ''}${minimize ? '.min' : ''}.js`
filename: `[name]${kind ? '.' + kind : ''}${minimize ? '.min' : ''}.js`
},
optimization: { minimize },
performance: {
Expand Down

0 comments on commit 55feb89

Please sign in to comment.