diff --git a/lighthouse-core/test/lib/minification-estimator-test.js b/lighthouse-core/test/lib/minification-estimator-test.js index 07cbf7b98bca..e04771723452 100644 --- a/lighthouse-core/test/lib/minification-estimator-test.js +++ b/lighthouse-core/test/lib/minification-estimator-test.js @@ -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', () => { @@ -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); + }); }); }); diff --git a/package.json b/package.json index 0d28092b964c..d4cd40f10808 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index 16a45e4053f2..924830e14d16 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"