Skip to content

Commit

Permalink
tests: add angular test for JS minification (#6138)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhulce committed Sep 29, 2018
1 parent 69d328d commit 23633e4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lighthouse-core/test/lib/minification-estimator-test.js
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
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
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

0 comments on commit 23633e4

Please sign in to comment.