Skip to content

Commit

Permalink
feat(cli): upgrade to Lighthouse 6.4.1 (#470)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Lighthouse 6.4.1 with new audits in assertion presets and affected scores.
  • Loading branch information
csabapalfi committed Oct 22, 2020
1 parent 99fcb6f commit 14c5769
Show file tree
Hide file tree
Showing 17 changed files with 27,240 additions and 72 deletions.
2 changes: 1 addition & 1 deletion packages/cli/package.json
Expand Up @@ -19,7 +19,7 @@
"express": "^4.17.1",
"inquirer": "^6.3.1",
"isomorphic-fetch": "^2.2.1",
"lighthouse": "6.2.0",
"lighthouse": "6.4.1",
"lighthouse-logger": "1.2.0",
"open": "^7.1.0",
"tmp": "^0.1.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/test/assert.test.js
Expand Up @@ -52,7 +52,7 @@ describe('Lighthouse CI assert CLI', () => {
it('should run the recommended preset', async () => {
const result = await run([`--preset=lighthouse:recommended`]);
expect(result.status).toEqual(1);
expect(result.failures.length).toMatchInlineSnapshot(`94`);
expect(result.failures.length).toMatchInlineSnapshot(`96`);
expect(result.warnings.length).toMatchInlineSnapshot(`19`);
expect(result.passes.length).toMatchInlineSnapshot(`0`);
expect(result.failures).toContain('deprecations failure');
Expand All @@ -62,7 +62,7 @@ describe('Lighthouse CI assert CLI', () => {
it('should run the no-pwa preset', async () => {
const result = await run([`--preset=lighthouse:no-pwa`]);
expect(result.status).toEqual(1);
expect(result.failures.length).toMatchInlineSnapshot(`83`);
expect(result.failures.length).toMatchInlineSnapshot(`85`);
expect(result.warnings.length).toMatchInlineSnapshot(`17`);
expect(result.passes.length).toMatchInlineSnapshot(`0`);
expect(result.failures).toContain('deprecations failure');
Expand All @@ -84,7 +84,7 @@ describe('Lighthouse CI assert CLI', () => {
const result = await run([`--preset=lighthouse:recommended`, '--include-passed-assertions']);
expect(result.status).toEqual(1);
expect(result.warnings.length).toMatchInlineSnapshot(`19`);
expect(result.failures.length).toMatchInlineSnapshot(`94`);
expect(result.failures.length).toMatchInlineSnapshot(`96`);
expect(result.passes.length).toMatchInlineSnapshot(`1`);
expect(result.passes).toContain('first-contentful-paint passing');
expect(result.failures).toContain('viewport failure');
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/test/cli.test.js
Expand Up @@ -37,6 +37,11 @@ describe('Lighthouse CI CLI', () => {
let projectAdminToken;
let urlToCollect;

beforeAll(async () => {
server = await startServer();
urlToCollect = `http://localhost:${server.port}/app/`;
});

afterAll(async () => {
if (server) {
server.process.kill();
Expand All @@ -47,11 +52,6 @@ describe('Lighthouse CI CLI', () => {
});

describe('server', () => {
it('should bring up the server and accept requests', async () => {
server = await startServer();
urlToCollect = `http://localhost:${server.port}/app/`;
});

it('should accept requests', async () => {
const response = await fetch(`http://localhost:${server.port}/v1/projects`);
const projects = await response.json();
Expand Down
Expand Up @@ -14,6 +14,8 @@ import lhr6A_ from '../../../../../test/fixtures/lh-6-0-0-coursehero-a.json';
import lhr6B_ from '../../../../../test/fixtures/lh-6-0-0-coursehero-b.json';
import lhr62A_ from '../../../../../test/fixtures/lh-6-2-0-coursehero-a.json';
import lhr62B_ from '../../../../../test/fixtures/lh-6-2-0-coursehero-b.json';
import lhr641A_ from '../../../../../test/fixtures/lh-6-4-1-coursehero-a.json';
import lhr641B_ from '../../../../../test/fixtures/lh-6-4-1-coursehero-b.json';

export default {
title: 'Build View/Audit Detail Pane',
Expand All @@ -27,10 +29,13 @@ const lhr6A = /** @type {any} */ (lhr6A_);
const lhr6B = /** @type {any} */ (lhr6B_);
const lhr62A = /** @type {any} */ (lhr62A_);
const lhr62B = /** @type {any} */ (lhr62B_);
const lhr641A = /** @type {any} */ (lhr641A_);
const lhr641B = /** @type {any} */ (lhr641B_);

const auditPairs5 = createAuditPairs(lhr5A, lhr5B);
const auditPairs6 = createAuditPairs(lhr6A, lhr6B);
const auditPairs62 = createAuditPairs(lhr62A, lhr62B);
const auditPairs641 = createAuditPairs(lhr641A, lhr641B);

export const Default = () => (
<AuditDetailPane
Expand Down Expand Up @@ -59,6 +64,15 @@ export const Version62 = () => (
/>
);

export const Version641 = () => (
<AuditDetailPane
selectedAuditId={auditPairs641[1].audit.id || ''}
setSelectedAuditId={action('setSelectedAuditId')}
pairs={auditPairs641}
baseLhr={lhr641B}
/>
);

/**
* @param {LH.Result} lhrA
* @param {LH.Result} lhrB
Expand Down
Expand Up @@ -12,6 +12,8 @@ import lhr6A_ from '../../../../test/fixtures/lh-6-0-0-coursehero-a.json';
import lhr6B_ from '../../../../test/fixtures/lh-6-0-0-coursehero-b.json';
import lhr62A_ from '../../../../test/fixtures/lh-6-2-0-coursehero-a.json';
import lhr62B_ from '../../../../test/fixtures/lh-6-2-0-coursehero-b.json';
import lhr641A_ from '../../../../test/fixtures/lh-6-4-1-coursehero-a.json';
import lhr641B_ from '../../../../test/fixtures/lh-6-4-1-coursehero-b.json';

export default {
title: 'Build View/LHR Comparison',
Expand All @@ -25,6 +27,8 @@ const lhr6A = /** @type {any} */ (lhr6A_);
const lhr6B = /** @type {any} */ (lhr6B_);
const lhr62A = /** @type {any} */ (lhr62A_);
const lhr62B = /** @type {any} */ (lhr62B_);
const lhr641A = /** @type {any} */ (lhr641A_);
const lhr641B = /** @type {any} */ (lhr641B_);

/** @param {{children: LHCI.PreactNode}} props */
const Wrapper = ({children}) => <div className="build-hash-selector">{children}</div>;
Expand All @@ -46,3 +50,9 @@ export const Version62 = () => (
<LhrComparison lhr={lhr62A} baseLhr={lhr62B} hookElements={{}} />
</Wrapper>
);

export const Version641 = () => (
<Wrapper>
<LhrComparison lhr={lhr641A} baseLhr={lhr641B} hookElements={{}} />
</Wrapper>
);
12 changes: 12 additions & 0 deletions packages/server/test/api/statistic-definitions.test.js
Expand Up @@ -13,6 +13,8 @@ const baseLhr5_ = require('../fixtures/lh-5-6-0-verge-a.json');
const baseLhr6_ = require('../fixtures/lh-6-0-0-coursehero-a.json');
/** @type {any} */
const baseLhr62_ = require('../fixtures/lh-6-2-0-coursehero-a.json');
/** @type {any} */
const baseLhr641_ = require('../fixtures/lh-6-4-1-coursehero-a.json');
const {definitions} = require('../../src/api/statistic-definitions.js');

describe('Statistic Definitions', () => {
Expand All @@ -22,6 +24,8 @@ describe('Statistic Definitions', () => {
const baseLhr6 = baseLhr6_;
/** @type {LH.Result} */
const baseLhr62 = baseLhr62_;
/** @type {LH.Result} */
const baseLhr641 = baseLhr641_;

describe('meta_lighthouse_version()', () => {
const run = definitions.meta_lighthouse_version;
Expand All @@ -30,6 +34,7 @@ describe('Statistic Definitions', () => {
expect(run([baseLhr5])).toEqual({value: 50600});
expect(run([baseLhr6])).toEqual({value: 60000});
expect(run([baseLhr62])).toEqual({value: 60200});
expect(run([baseLhr641])).toEqual({value: 60401});
expect(run([{...baseLhr5, lighthouseVersion: '1.2.3-beta.0'}])).toEqual({value: 10203});
});

Expand All @@ -50,6 +55,7 @@ describe('Statistic Definitions', () => {
expect(run([low, high, baseLhr5]).value).toBeCloseTo(43223.58);
expect(run([baseLhr6, low, high]).value).toBeCloseTo(20253.43);
expect(run([high, baseLhr62, low]).value).toBeCloseTo(19669.83);
expect(run([high, baseLhr641, low]).value).toBeCloseTo(19945.48);
});
});

Expand All @@ -64,6 +70,7 @@ describe('Statistic Definitions', () => {
expect(run([low, high, baseLhr5]).value).toBeCloseTo(0.18);
expect(run([baseLhr6, low, high]).value).toBeCloseTo(0.16);
expect(run([high, baseLhr62, low]).value).toBeCloseTo(0.28);
expect(run([high, baseLhr641, low]).value).toBeCloseTo(0.2);
});
});

Expand All @@ -78,6 +85,7 @@ describe('Statistic Definitions', () => {
expect(run([low, high, baseLhr5]).value).toBeCloseTo(0.01);
expect(run([baseLhr6, low, high]).value).toBeCloseTo(0.01);
expect(run([high, baseLhr62, low]).value).toBeCloseTo(0.01);
expect(run([high, baseLhr641, low]).value).toBeCloseTo(0.01);
});
});

Expand All @@ -92,6 +100,7 @@ describe('Statistic Definitions', () => {
expect(run([low, high, baseLhr5]).value).toBeCloseTo(0.99);
expect(run([baseLhr6, low, high]).value).toBeCloseTo(0.99);
expect(run([high, baseLhr62, low]).value).toBeCloseTo(0.99);
expect(run([high, baseLhr641, low]).value).toBeCloseTo(0.99);
});
});

Expand All @@ -100,12 +109,15 @@ describe('Statistic Definitions', () => {
expect(definitions['auditgroup_a11y-aria_pass']([baseLhr5])).toEqual({value: 7});
expect(definitions['auditgroup_a11y-aria_pass']([baseLhr6])).toEqual({value: 10});
expect(definitions['auditgroup_a11y-aria_pass']([baseLhr62])).toEqual({value: 10});
expect(definitions['auditgroup_a11y-aria_pass']([baseLhr641])).toEqual({value: 10});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr5])).toEqual({value: 0});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr6])).toEqual({value: 1});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr62])).toEqual({value: 1});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baseLhr641])).toEqual({value: 1});
expect(definitions['auditgroup_a11y-aria_na']([baseLhr5])).toEqual({value: 0});
expect(definitions['auditgroup_a11y-aria_na']([baseLhr6])).toEqual({value: 2});
expect(definitions['auditgroup_a11y-aria_na']([baseLhr62])).toEqual({value: 2});
expect(definitions['auditgroup_a11y-aria_na']([baseLhr641])).toEqual({value: 2});
});
});
});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -28,11 +28,11 @@ describe('Project dashboard', () => {

expect(commits).toMatchInlineSnapshot(`
Array [
"1242build 8call_splitmasterMay 18 6:00 AM",
"1241build 7call_splitmasterMay 17 6:00 AM",
"1240build 6call_splitmasterMay 16 6:00 AM",
"1239build 5call_splitmasterMay 15 6:00 AM",
"1238build 4call_splitmasterMay 14 6:00 AM",
"1237build 3call_splitmasterMay 13 6:00 AM",
"1236build 2call_splitmasterMay 12 6:00 AM",
]
`);
});
Expand Down
13,571 changes: 13,571 additions & 0 deletions packages/server/test/fixtures/lh-6-4-1-coursehero-a.json

Large diffs are not rendered by default.

13,545 changes: 13,545 additions & 0 deletions packages/server/test/fixtures/lh-6-4-1-coursehero-b.json

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions packages/server/test/test-utils.js
Expand Up @@ -88,6 +88,8 @@ function createActualTestDataset() {
{...baseBuild, id: '3', hash: '1238', commitMessage: 'build 4', runAt: runAt(4)},
{...baseBuild, id: '4', hash: '1239', commitMessage: 'build 5', runAt: runAt(5)},
{...baseBuild, id: '5', hash: '1240', commitMessage: 'build 6', runAt: runAt(6)},
{...baseBuild, id: '6', hash: '1241', commitMessage: 'build 7', runAt: runAt(7)},
{...baseBuild, id: '7', hash: '1242', commitMessage: 'build 8', runAt: runAt(8)},
],
runs: [
{...baseRun, id: '0', buildId: '0', url, lhr: lhr('lh-5-6-0-verge-a.json')},
Expand All @@ -96,6 +98,8 @@ function createActualTestDataset() {
{...baseRun, id: '3', buildId: '3', url, lhr: lhr('lh-6-0-0-coursehero-b.json')},
{...baseRun, id: '4', buildId: '4', url, lhr: lhr('lh-6-2-0-coursehero-a.json')},
{...baseRun, id: '5', buildId: '5', url, lhr: lhr('lh-6-2-0-coursehero-b.json')},
{...baseRun, id: '6', buildId: '6', url, lhr: lhr('lh-6-4-1-coursehero-a.json')},
{...baseRun, id: '7', buildId: '7', url, lhr: lhr('lh-6-4-1-coursehero-b.json')},
],
};
}
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/utils/package.json
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"isomorphic-fetch": "^2.2.1",
"js-yaml": "^3.13.1",
"lighthouse": "6.2.0",
"lighthouse": "6.4.1",
"tree-kill": "^1.2.1"
}
}
2 changes: 2 additions & 0 deletions packages/utils/src/presets/all.js
Expand Up @@ -96,6 +96,7 @@ module.exports = {
'offscreen-images': ['error', {}],
'password-inputs-can-be-pasted-into': ['error', {}],
'performance-budget': ['error', {}],
'preload-fonts': ['error', {}],
'redirects-http': ['error', {}],
'render-blocking-resources': ['error', {}],
'robots-txt': ['error', {}],
Expand Down Expand Up @@ -124,6 +125,7 @@ module.exports = {
'uses-text-compression': ['error', {}],
'uses-webp-images': ['error', {}],
'valid-lang': ['error', {}],
'valid-source-maps': ['error', {}],
'video-caption': ['error', {}],
'video-description': ['error', {}],
'without-javascript': ['error', {}],
Expand Down

0 comments on commit 14c5769

Please sign in to comment.