Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add angular test for JS minification #6138

Merged
merged 2 commits into from
Sep 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lighthouse-core/test/lib/minification-estimator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
*/
'use strict';

const fs = require('fs');
const assert = require('assert');
const {computeCSSTokenLength, computeJSTokenLength} = require('../../lib/minification-estimator');

const angularFullScript = fs.readFileSync(require.resolve('angular/angular.js'), 'utf8');

/* eslint-env jest */

describe('minification estimator', () => {
Expand Down Expand Up @@ -184,5 +187,11 @@ describe('minification estimator', () => {

assert.equal(computeJSTokenLength(js), 9);
});

it('should handle large, real javscript files', () => {
assert.equal(angularFullScript.length, 1364217);
// 1 - 405199 / 1364217 = estimated 70% smaller minified
assert.equal(computeJSTokenLength(angularFullScript), 405199);
});
});
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"@types/update-notifier": "^1.0.2",
"@types/ws": "^4.0.1",
"@types/yargs": "^8.0.2",
"angular": "^1.7.4",
"babel-core": "^6.26.0",
"bundlesize": "^0.14.4",
"chalk": "^2.4.1",
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ amdefine@>=0.0.4:
version "1.0.0"
resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.0.tgz#fd17474700cb5cc9c2b709f0be9d23ce3c198c33"

angular@^1.7.4:
version "1.7.4"
resolved "https://registry.yarnpkg.com/angular/-/angular-1.7.4.tgz#c1bf4884c2d470c06907737a1bf0835a9f646f31"

ansi-align@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-1.1.0.tgz#2f0c1658829739add5ebb15e6b0c6e3423f016ba"
Expand Down