Skip to content

Commit

Permalink
feat: upgrade to lighthouse 12.0.0 (#1035)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: upgrade to lighthouse 12.0.0
  • Loading branch information
connorjclark authored May 7, 2024
1 parent 19c7ca6 commit cc564a6
Show file tree
Hide file tree
Showing 32 changed files with 75,309 additions and 107 deletions.
1 change: 0 additions & 1 deletion .lighthouserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module.exports = {
'unused-javascript': 'off',

label: 'off',
'content-width': 'off',
'color-contrast': 'off',
bypass: 'off',
'tap-targets': 'off',
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ _Optional_ The maximum number of requests to send to the PageSpeed Insights API
##### `psiCollectCron.sites[i].categories`
_Optional_ An array containing the categories to test for each url in this site. Defaults to `['performance', 'accessibility', 'best-practices', 'pwa', 'seo']` (all categories).
_Optional_ An array containing the categories to test for each url in this site. Defaults to `['performance', 'accessibility', 'best-practices', 'seo']` (all categories).
##### `psiCollectCron.sites[i].strategy`
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"https-proxy-agent": "^5.0.0",
"inquirer": "^6.3.1",
"isomorphic-fetch": "^3.0.0",
"lighthouse": "11.4.0",
"lighthouse": "12.0.0",
"lighthouse-logger": "1.2.0",
"open": "^7.1.0",
"tmp": "^0.1.0",
Expand Down
13 changes: 6 additions & 7 deletions packages/cli/test/assert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('Lighthouse CI assert CLI', () => {
if (!fs.existsSync(lighthouseciDir)) fs.mkdirSync(lighthouseciDir, {recursive: true});
const fakeLhrPath = path.join(lighthouseciDir, 'lhr-12345.json');
const fakeLhr = {categories: {}, audits: {}};
fakeLhr.categories.pwa = {score: 0};
fakeLhr.audits['performance-budget'] = {score: 0};
for (const key of Object.keys(fullPreset.assertions)) {
fakeLhr.audits[key] = {score: passingAuditIds.includes(key) ? 1 : 0, details: {items: [{}]}};
Expand All @@ -55,8 +54,8 @@ 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(`115`);
expect(result.warnings.length).toMatchInlineSnapshot(`17`);
expect(result.failures.length).toMatchInlineSnapshot(`108`);
expect(result.warnings.length).toMatchInlineSnapshot(`16`);
expect(result.passes.length).toMatchInlineSnapshot(`0`);
expect(result.failures).toContain('deprecations failure');
expect(result.failures).toContain('viewport failure');
Expand All @@ -65,8 +64,8 @@ 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(`109`);
expect(result.warnings.length).toMatchInlineSnapshot(`16`);
expect(result.failures.length).toMatchInlineSnapshot(`107`);
expect(result.warnings.length).toMatchInlineSnapshot(`15`);
expect(result.passes.length).toMatchInlineSnapshot(`0`);
expect(result.failures).toContain('deprecations failure');
expect(result.failures).not.toContain('viewport failure');
Expand All @@ -91,8 +90,8 @@ describe('Lighthouse CI assert CLI', () => {
it('should return passing audits', async () => {
const result = await run([`--preset=lighthouse:recommended`, '--include-passed-assertions']);
expect(result.status).toEqual(1);
expect(result.warnings.length).toMatchInlineSnapshot(`17`);
expect(result.failures.length).toMatchInlineSnapshot(`115`);
expect(result.warnings.length).toMatchInlineSnapshot(`16`);
expect(result.failures.length).toMatchInlineSnapshot(`108`);
expect(result.passes.length).toMatchInlineSnapshot(`1`);
expect(result.passes).toContain('first-contentful-paint passing');
expect(result.failures).toContain('viewport failure');
Expand Down
38 changes: 19 additions & 19 deletions packages/cli/test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ describe('Lighthouse CI CLI', () => {
it('should assert failures', async () => {
const {stdout, stderr, status} = await runCLI([
'assert',
`--assertions.installable-manifest=error`,
`--assertions.prioritize-lcp-image=error`,
]);

expect(stdout).toMatchInlineSnapshot(`""`);
Expand All @@ -327,9 +327,9 @@ describe('Lighthouse CI CLI', () => {
1 result(s) for http://localhost:XXXX/app/ :
[31mX[0m [1minstallable-manifest[0m failure for [1mminScore[0m assertion
Web app manifest or service worker do not meet the installability requirements
https://developer.chrome.com/docs/lighthouse/pwa/installable-manifest/
[31mX[0m [1mprioritize-lcp-image[0m failure for [1mminScore[0m assertion
Preload Largest Contentful Paint image
https://web.dev/articles/optimize-lcp#optimize_when_the_resource_is_discovered
expected: >=0.9
found: 0
Expand All @@ -356,13 +356,13 @@ describe('Lighthouse CI CLI', () => {
1 result(s) for http://localhost:XXXX/app/ :
[31mX[0m [1mperformance-budget[0m.script.size failure for [1mmaxNumericValue[0m assertion
Performance budget
https://developers.google.com/web/tools/lighthouse/audits/budgets
[31mX[0m [1mprioritize-lcp-image[0m failure for [1mminScore[0m assertion
Preload Largest Contentful Paint image
https://web.dev/articles/optimize-lcp#optimize_when_the_resource_is_discovered
expected: <=[32mXXXX[0m
found: [31mXXXX[0m
[2mall values: XXXX[0m
expected: >=[32m1[0m
found: [31m0[0m
[2mall values: 0, 0[0m
Assertion failed. Exiting with status code 1.
"
Expand All @@ -379,9 +379,9 @@ describe('Lighthouse CI CLI', () => {
1 result(s) for http://localhost:XXXX/app/ :
[31mX[0m [1minstallable-manifest[0m failure for [1mminScore[0m assertion
Web app manifest or service worker do not meet the installability requirements
https://developer.chrome.com/docs/lighthouse/pwa/installable-manifest/
[31mX[0m [1mprioritize-lcp-image[0m failure for [1mminScore[0m assertion
Preload Largest Contentful Paint image
https://web.dev/articles/optimize-lcp#optimize_when_the_resource_is_discovered
expected: >=0.9
found: 0
Expand Down Expand Up @@ -416,13 +416,13 @@ describe('Lighthouse CI CLI', () => {
all values: XXXX, XXXX
[31mX[0m [1mperformance-budget[0m.script.size failure for [1mmaxNumericValue[0m assertion
Performance budget
https://developers.google.com/web/tools/lighthouse/audits/budgets
[31mX[0m [1mprioritize-lcp-image[0m failure for [1mminScore[0m assertion
Preload Largest Contentful Paint image
https://web.dev/articles/optimize-lcp#optimize_when_the_resource_is_discovered
expected: <=[32mXXXX[0m
found: [31mXXXX[0m
[2mall values: XXXX[0m
expected: >=[32m1[0m
found: [31m0[0m
[2mall values: 0, 0[0m
Assertion failed. Exiting with status code 1.
"
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/fixtures/lighthouserc-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"matchingUrlPattern": "app",
"assertions": {
"installable-manifest": "error"
"prioritize-lcp-image": "error"
}
},
{
Expand Down
1 change: 0 additions & 1 deletion packages/cli/test/fixtures/lighthouserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module.exports = {
ci: {
assert: {
assertions: {
'categories.pwa': 'off',
'speed-index': ['error', {minScore: 0.8}],
interactive: ['error', {minScore: 0.8}],
'performance-budget': ['error', {minScore: 1}],
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/test/fixtures/lighthouserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
"ci": {
"assert": {
"assertions": {
"categories.pwa": "off",
"speed-index": ["error", {"minScore": 0.8}],
"interactive": ["error", {"minScore": 0.8}],
"performance-budget": ["error", {"minScore": 1}]
"prioritize-lcp-image": ["error", {"minScore": 1}]
}
},
"collect": {
Expand Down
7 changes: 3 additions & 4 deletions packages/cli/test/upload-url-hash.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('Lighthouse CI upload filesystem reports with url hash', () => {

const writeLhr = () => {
const fakeLhr = {finalUrl: 'foo.com', categories: {}, audits: {}};
fakeLhr.categories.pwa = {score: 0};
fakeLhr.categories.performance = {score: 0};
fakeLhr.audits['performance-budget'] = {score: 0};
for (const key of Object.keys(fullPreset.assertions)) {
Expand Down Expand Up @@ -95,21 +94,21 @@ describe('Lighthouse CI upload filesystem reports with url hash', () => {
isRepresentativeRun: true,
htmlPath: path.join(outputDir, 'www_example_com-_-_page1-2022_10_25_22_34_01.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_-_page1-2022_10_25_22_34_01.report.json'),
summary: {performance: 0.5, pwa: 0},
summary: {performance: 0.5},
},
{
url: 'https://www.example.com/#/page2',
isRepresentativeRun: true,
htmlPath: path.join(outputDir, 'www_example_com-_-_page2-2022_10_25_22_34_02.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_-_page2-2022_10_25_22_34_02.report.json'),
summary: {performance: 0.5, pwa: 0},
summary: {performance: 0.5},
},
{
url: 'https://www.example.com/#/page3',
isRepresentativeRun: true,
htmlPath: path.join(outputDir, 'www_example_com-_-_page3-2022_10_25_22_34_03.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_-_page3-2022_10_25_22_34_03.report.json'),
summary: {performance: 0.5, pwa: 0},
summary: {performance: 0.5},
},
]);
}, 15000);
Expand Down
7 changes: 3 additions & 4 deletions packages/cli/test/upload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe('Lighthouse CI upload CLI', () => {

const writeLhr = () => {
const fakeLhr = {finalUrl: 'foo.com', categories: {}, audits: {}};
fakeLhr.categories.pwa = {score: 0};
fakeLhr.categories.performance = {score: 0};
fakeLhr.audits['performance-budget'] = {score: 0};
for (const key of Object.keys(fullPreset.assertions)) {
Expand Down Expand Up @@ -205,21 +204,21 @@ describe('Lighthouse CI upload CLI', () => {
isRepresentativeRun: false,
htmlPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_01.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_01.report.json'),
summary: {performance: 0, pwa: 0},
summary: {performance: 0},
},
{
url: 'https://www.example.com/page',
isRepresentativeRun: false,
htmlPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_02.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_02.report.json'),
summary: {performance: 0, pwa: 0},
summary: {performance: 0},
},
{
url: 'https://www.example.com/page',
isRepresentativeRun: true,
htmlPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_03.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_03.report.json'),
summary: {performance: 0.5, pwa: 0},
summary: {performance: 0.5},
},
]);
}, 15000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import lhr1010A_ from '../../../../../test/fixtures/lh-10-1-0-coursehero-a.json'
import lhr1010B_ from '../../../../../test/fixtures/lh-10-1-0-coursehero-b.json';
import lhr1140A_ from '../../../../../test/fixtures/lh-11-4-0-coursehero-a.json';
import lhr1140B_ from '../../../../../test/fixtures/lh-11-4-0-coursehero-b.json';
import lhr1200A_ from '../../../../../test/fixtures/lh-12-0-0-coursehero-a.json';
import lhr1200B_ from '../../../../../test/fixtures/lh-12-0-0-coursehero-b.json';
import lhrSubitemsA_ from '../../../../../test/fixtures/lh-subitems-a.json';
import lhrSubitemsB_ from '../../../../../test/fixtures/lh-subitems-b.json';
import lhrPsi800A_ from '../../../../../test/fixtures/psi-8-0-0-dkdev-a.json';
Expand Down Expand Up @@ -54,6 +56,8 @@ const lhr1010A = /** @type {any} */ (lhr1010A_);
const lhr1010B = /** @type {any} */ (lhr1010B_);
const lhr1140A = /** @type {any} */ (lhr1140A_);
const lhr1140B = /** @type {any} */ (lhr1140B_);
const lhr1200A = /** @type {any} */ (lhr1200A_);
const lhr1200B = /** @type {any} */ (lhr1200B_);
const lhrSubitemsA = /** @type {any} */ (lhrSubitemsA_);
const lhrSubitemsB = /** @type {any} */ (lhrSubitemsB_);
const lhrPsi800A = /** @type {any} */ (lhrPsi800A_);
Expand All @@ -68,6 +72,7 @@ const auditPairs800 = createAuditPairs(lhr800A, lhr800B);
const auditPairs930 = createAuditPairs(lhr930A, lhr930B);
const auditPairs1010 = createAuditPairs(lhr1010A, lhr1010B);
const auditPairs1140 = createAuditPairs(lhr1140A, lhr1140B);
const auditPairs1200 = createAuditPairs(lhr1200A, lhr1200B);
const auditPairsPsi800 = createAuditPairs(lhrPsi800A, lhrPsi800B);
const auditPairsSubitems = createAuditPairs(lhrSubitemsA, lhrSubitemsB, {
filter: pair =>
Expand Down Expand Up @@ -161,6 +166,15 @@ export const Version1140 = () => (
/>
);

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

export const VersionPsi800 = () => (
<AuditDetailPane
selectedAuditId={auditPairsPsi800[1].audit.id || ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import lhr1010A_ from '../../../../test/fixtures/lh-10-1-0-coursehero-a.json';
import lhr1010B_ from '../../../../test/fixtures/lh-10-1-0-coursehero-b.json';
import lhr1140A_ from '../../../../test/fixtures/lh-11-4-0-coursehero-a.json';
import lhr1140B_ from '../../../../test/fixtures/lh-11-4-0-coursehero-b.json';
import lhr1200A_ from '../../../../test/fixtures/lh-12-0-0-coursehero-a.json';
import lhr1200B_ from '../../../../test/fixtures/lh-12-0-0-coursehero-b.json';
import lhrPsi800A_ from '../../../../test/fixtures/psi-8-0-0-dkdev-a.json';
import lhrPsi800B_ from '../../../../test/fixtures/psi-8-0-0-dkdev-b.json';

Expand All @@ -50,6 +52,8 @@ const lhr1010A = /** @type {any} */ (lhr1010A_);
const lhr1010B = /** @type {any} */ (lhr1010B_);
const lhr1140A = /** @type {any} */ (lhr1140A_);
const lhr1140B = /** @type {any} */ (lhr1140B_);
const lhr1200A = /** @type {any} */ (lhr1200A_);
const lhr1200B = /** @type {any} */ (lhr1200B_);
const lhrPsi800A = /** @type {any} */ (lhrPsi800A_);
const lhrPsi800B = /** @type {any} */ (lhrPsi800B_);

Expand Down Expand Up @@ -110,6 +114,12 @@ export const Version1140 = () => (
</Wrapper>
);

export const Version1200 = () => (
<Wrapper>
<LhrComparison lhr={lhr1200A} baseLhr={lhr1200B} hookElements={{}} />
</Wrapper>
);

export const VersionPsi800 = () => (
<Wrapper>
<LhrComparison lhr={lhrPsi800A} baseLhr={lhrPsi800B} hookElements={{}} />
Expand Down
12 changes: 12 additions & 0 deletions packages/server/test/api/statistic-definitions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const baselhr930_ = require('../fixtures/lh-9-3-0-coursehero-a.json');
const baselhr1010_ = require('../fixtures/lh-10-1-0-coursehero-a.json');
/** @type {any} */
const baselhr1140_ = require('../fixtures/lh-11-4-0-coursehero-a.json');
/** @type {any} */
const baselhr1200_ = require('../fixtures/lh-12-0-0-coursehero-a.json');
const {definitions} = require('../../src/api/statistic-definitions.js');

describe('Statistic Definitions', () => {
Expand All @@ -46,6 +48,8 @@ describe('Statistic Definitions', () => {
const baselhr1010 = baselhr1010_;
/** @type {LH.Result} */
const baselhr1140 = baselhr1140_;
/** @type {LH.Result} */
const baselhr1200 = baselhr1200_;

describe('meta_lighthouse_version()', () => {
const run = definitions.meta_lighthouse_version;
Expand All @@ -60,6 +64,7 @@ describe('Statistic Definitions', () => {
expect(run([baselhr930])).toEqual({value: 90300});
expect(run([baselhr1010])).toEqual({value: 100100});
expect(run([baselhr1140])).toEqual({value: 110400});
expect(run([baselhr1200])).toEqual({value: 120000});
expect(run([{...baseLhr5, lighthouseVersion: '1.2.3-beta.0'}])).toEqual({value: 10203});
});

Expand All @@ -86,6 +91,7 @@ describe('Statistic Definitions', () => {
expect(run([high, baselhr930, low]).value).toBeCloseTo(20525.578);
expect(run([high, baselhr1010, low]).value).toBeCloseTo(21627.392);
expect(run([high, baselhr1140, low]).value).toBeCloseTo(80796.283);
expect(run([high, baselhr1200, low]).value).toBeCloseTo(82970.673);
});
});

Expand All @@ -106,6 +112,7 @@ describe('Statistic Definitions', () => {
expect(run([high, baselhr930, low]).value).toBeCloseTo(0.23);
expect(run([high, baselhr1010, low]).value).toBeCloseTo(0.21);
expect(run([high, baselhr1140, low]).value).toBeCloseTo(0.32);
expect(run([high, baselhr1200, low]).value).toBeCloseTo(0.34);
});
});

Expand All @@ -126,6 +133,7 @@ describe('Statistic Definitions', () => {
expect(run([high, baselhr930, low]).value).toBeCloseTo(0.01);
expect(run([high, baselhr1010, low]).value).toBeCloseTo(0.01);
expect(run([high, baselhr1140, low]).value).toBeCloseTo(0.01);
expect(run([high, baselhr1200, low]).value).toBeCloseTo(0.01);
});
});

Expand All @@ -146,6 +154,7 @@ describe('Statistic Definitions', () => {
expect(run([high, baselhr930, low]).value).toBeCloseTo(0.99);
expect(run([high, baselhr1010, low]).value).toBeCloseTo(0.99);
expect(run([high, baselhr1140, low]).value).toBeCloseTo(0.99);
expect(run([high, baselhr1200, low]).value).toBeCloseTo(0.99);
});
});

Expand All @@ -160,6 +169,7 @@ describe('Statistic Definitions', () => {
expect(definitions['auditgroup_a11y-aria_pass']([baselhr930])).toEqual({value: 8});
expect(definitions['auditgroup_a11y-aria_pass']([baselhr1010])).toEqual({value: 8});
expect(definitions['auditgroup_a11y-aria_pass']([baselhr1140])).toEqual({value: 9});
expect(definitions['auditgroup_a11y-aria_pass']([baselhr1200])).toEqual({value: 12});
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});
Expand All @@ -169,6 +179,7 @@ describe('Statistic Definitions', () => {
expect(definitions['auditgroup_a11y-color-contrast_fail']([baselhr930])).toEqual({value: 1});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baselhr1010])).toEqual({value: 1});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baselhr1140])).toEqual({value: 1});
expect(definitions['auditgroup_a11y-color-contrast_fail']([baselhr1200])).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});
Expand All @@ -178,6 +189,7 @@ describe('Statistic Definitions', () => {
expect(definitions['auditgroup_a11y-aria_na']([baselhr930])).toEqual({value: 9});
expect(definitions['auditgroup_a11y-aria_na']([baselhr1010])).toEqual({value: 9});
expect(definitions['auditgroup_a11y-aria_na']([baselhr1140])).toEqual({value: 9});
expect(definitions['auditgroup_a11y-aria_na']([baselhr1200])).toEqual({value: 9});
});
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cc564a6

Please sign in to comment.