lighthouse 10.0.0-dev.20230213 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/core/audits/dobetterweb/doctype.d.ts +3 -2
  2. package/core/audits/dobetterweb/doctype.js +15 -4
  3. package/core/audits/dobetterweb/paste-preventing-inputs.js +2 -2
  4. package/core/gather/driver/network-monitor.js +1 -3
  5. package/core/gather/gatherers/bf-cache-failures.js +7 -8
  6. package/package.json +1 -1
  7. package/shared/localization/locales/en-US.json +1 -1
  8. package/shared/localization/locales/en-XL.json +1 -1
  9. package/.codecov.yml +0 -22
  10. package/.cz-config.js +0 -24
  11. package/.gitattributes +0 -5
  12. package/.mailmap +0 -6
  13. package/CODE_OF_CONDUCT.md +0 -93
  14. package/eslint-local-rules.cjs +0 -106
  15. package/flow-report/test/app-test.d.ts +0 -7
  16. package/flow-report/test/app-test.tsx +0 -52
  17. package/flow-report/test/common-test.d.ts +0 -7
  18. package/flow-report/test/common-test.tsx +0 -103
  19. package/flow-report/test/flow-report-pptr-test.d.ts +0 -7
  20. package/flow-report/test/flow-report-pptr-test.ts +0 -59
  21. package/flow-report/test/header-test.d.ts +0 -7
  22. package/flow-report/test/header-test.tsx +0 -55
  23. package/flow-report/test/run-flow-report-tests.sh +0 -20
  24. package/flow-report/test/sample-flow.d.ts +0 -7
  25. package/flow-report/test/sample-flow.ts +0 -17
  26. package/flow-report/test/setup/env-setup.d.ts +0 -11
  27. package/flow-report/test/setup/env-setup.ts +0 -55
  28. package/flow-report/test/sidebar/flow-test.d.ts +0 -7
  29. package/flow-report/test/sidebar/flow-test.tsx +0 -65
  30. package/flow-report/test/sidebar/sidebar-test.d.ts +0 -7
  31. package/flow-report/test/sidebar/sidebar-test.tsx +0 -116
  32. package/flow-report/test/summary/category-test.d.ts +0 -7
  33. package/flow-report/test/summary/category-test.tsx +0 -206
  34. package/flow-report/test/summary/summary-test.d.ts +0 -7
  35. package/flow-report/test/summary/summary-test.tsx +0 -124
  36. package/flow-report/test/topbar-test.d.ts +0 -7
  37. package/flow-report/test/topbar-test.tsx +0 -84
  38. package/flow-report/test/util-test.d.ts +0 -7
  39. package/flow-report/test/util-test.tsx +0 -133
  40. package/flow-report/test/wrappers/category-score-test.d.ts +0 -7
  41. package/flow-report/test/wrappers/category-score-test.tsx +0 -84
  42. package/flow-report/test/wrappers/markdown-test.d.ts +0 -7
  43. package/flow-report/test/wrappers/markdown-test.tsx +0 -17
  44. package/report/test/clients/bundle-test.js +0 -65
  45. package/report/test/generator/file-namer-test.js +0 -27
  46. package/report/test/generator/report-generator-test.js +0 -160
  47. package/report/test/renderer/__snapshots__/report-renderer-axe-test.js.snap +0 -15
  48. package/report/test/renderer/category-renderer-test.js +0 -575
  49. package/report/test/renderer/components-test.js +0 -124
  50. package/report/test/renderer/crc-details-renderer-test.js +0 -116
  51. package/report/test/renderer/details-renderer-test.js +0 -882
  52. package/report/test/renderer/dom-test.js +0 -257
  53. package/report/test/renderer/element-screenshot-renderer-test.js +0 -183
  54. package/report/test/renderer/i18n-formatter-test.js +0 -179
  55. package/report/test/renderer/performance-category-renderer-test.js +0 -417
  56. package/report/test/renderer/pwa-category-renderer-test.js +0 -301
  57. package/report/test/renderer/report-renderer-axe-test.js +0 -85
  58. package/report/test/renderer/report-renderer-test.js +0 -268
  59. package/report/test/renderer/report-ui-features-test.js +0 -773
  60. package/report/test/renderer/report-utils-test.js +0 -219
  61. package/report/test/renderer/snippet-renderer-test.js +0 -291
  62. package/report/test/renderer/text-encoding-test.js +0 -43
  63. package/report/test-assets/faux-psi-template.html +0 -177
  64. package/report/test-assets/faux-psi.d.ts +0 -34
  65. package/report/test-assets/faux-psi.js +0 -168
  66. package/report/test-assets/lhr-3.0.0.json +0 -2332
  67. package/report/test-assets/lhr-4.3.0.json +0 -4754
  68. package/report/test-assets/lhr-5.0.0.json +0 -5994
  69. package/report/test-assets/lhr-6.0.0.json +0 -7222
  70. package/report/test-assets/lhr-8.5.0.json +0 -8679
  71. package/shared/test/localization/format-test.js +0 -430
  72. package/shared/test/localization/locales-test.js +0 -45
  73. package/shared/test/localization/swap-locale-test.js +0 -127
  74. package/shared/test/util-test.js +0 -214
  75. package/vercel.json +0 -6
@@ -1,160 +0,0 @@
1
- /**
2
- * @license Copyright 2017 The Lighthouse Authors. All Rights Reserved.
3
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5
- */
6
- 'use strict';
7
-
8
- /* eslint-disable no-irregular-whitespace */
9
-
10
- import assert from 'assert/strict';
11
- import fs from 'fs';
12
-
13
- import csvValidator from 'csv-validator';
14
-
15
- import {ReportGenerator} from '../../generator/report-generator.js';
16
- import {readJson} from '../../../core/test/test-utils.js';
17
-
18
- const sampleResults = readJson('core/test/results/sample_v2.json');
19
- const sampleFlowResult = readJson('core/test/fixtures/fraggle-rock/reports/sample-flow-result.json');
20
-
21
- describe('ReportGenerator', () => {
22
- describe('#replaceStrings', () => {
23
- it('should replace all occurrences', () => {
24
- const source = '%foo! %foo %bar!';
25
- const result = ReportGenerator.replaceStrings(source, [
26
- {search: '%foo', replacement: 'hey'},
27
- {search: '%bar', replacement: 'you'},
28
- ]);
29
-
30
- assert.equal(result, 'hey! hey you!');
31
- });
32
-
33
- it('should not replace serial occurences', () => {
34
- const result = ReportGenerator.replaceStrings('%1', [
35
- {search: '%1', replacement: '%2'},
36
- {search: '%2', replacement: 'pwnd'},
37
- ]);
38
-
39
- assert.equal(result, '%2');
40
- });
41
- });
42
-
43
- describe('#generateHtmlReport', () => {
44
- it('should return html', () => {
45
- const result = ReportGenerator.generateReportHtml({});
46
- assert.ok(result.includes('doctype html'), 'includes doctype');
47
- assert.ok(result.trim().match(/<\/html>$/), 'ends with HTML tag');
48
- });
49
-
50
- it('should inject the report JSON', () => {
51
- const code = 'hax\u2028hax</script><script>console.log("pwned");%%LIGHTHOUSE_JAVASCRIPT%%';
52
- const result = ReportGenerator.generateReportHtml({code});
53
- assert.ok(result.includes('"code":"hax\\u2028'), 'injects the json');
54
- assert.ok(result.includes('hax\\u003c/script'), 'escapes HTML tags');
55
- assert.ok(result.includes('LIGHTHOUSE_JAVASCRIPT'), 'cannot be tricked');
56
- });
57
-
58
- it('should inject the report CSS', () => {
59
- const result = ReportGenerator.generateReportHtml({});
60
- assert.ok(!result.includes('/*%%LIGHTHOUSE_CSS%%*/'));
61
- assert.ok(result.includes('--color-green'));
62
- });
63
-
64
- it('should inject the report renderer javascript', () => {
65
- const result = ReportGenerator.generateReportHtml({});
66
- assert.ok(result.includes('configSettings.channel||"unknown"'), 'injects the script');
67
- assert.ok(result.includes('robustness: <\\/script'), 'escapes HTML tags in javascript');
68
- assert.ok(result.includes('pre$`post'), 'does not break from String.replace');
69
- assert.ok(result.includes('LIGHTHOUSE_JSON'), 'cannot be tricked');
70
- });
71
- });
72
-
73
- describe('#generateReport', () => {
74
- it('creates JSON for results', () => {
75
- const jsonOutput = ReportGenerator.generateReport(sampleResults, 'json');
76
- assert.doesNotThrow(_ => JSON.parse(jsonOutput));
77
- });
78
-
79
- it('creates JSON for flow result', () => {
80
- const jsonOutput = ReportGenerator.generateReport(sampleFlowResult, 'json');
81
- assert.doesNotThrow(_ => JSON.parse(jsonOutput));
82
- });
83
-
84
- it('creates HTML for results', () => {
85
- const htmlOutput = ReportGenerator.generateReport(sampleResults, 'html');
86
- assert.ok(/<!doctype/gim.test(htmlOutput));
87
- assert.ok(/<html lang="en"/gim.test(htmlOutput));
88
- });
89
-
90
- it('creates HTML for flow result', () => {
91
- const htmlOutput = ReportGenerator.generateReport(sampleFlowResult, 'html');
92
- assert.ok(/<!doctype/gim.test(htmlOutput));
93
- assert.ok(/<html lang="en"/gim.test(htmlOutput));
94
- });
95
-
96
- it('creates CSV for results', async () => {
97
- const path = './.results-as-csv.csv';
98
-
99
- const csvOutput = ReportGenerator.generateReport(sampleResults, 'csv');
100
- fs.writeFileSync(path, csvOutput);
101
-
102
- const lines = csvOutput.split('\n');
103
- expect(lines.length).toBeGreaterThan(100);
104
- expect(lines.slice(0, 15).join('\n')).toMatchInlineSnapshot(`
105
- "\\"requestedUrl\\",\\"finalDisplayedUrl\\",\\"fetchTime\\",\\"gatherMode\\"
106
- \\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"http://localhost:10200/dobetterweb/dbw_tester.html\\",\\"2021-09-07T20:11:11.853Z\\",\\"navigation\\"
107
-
108
- category,score
109
- \\"performance\\",\\"0.28\\"
110
- \\"accessibility\\",\\"0.77\\"
111
- \\"best-practices\\",\\"0.33\\"
112
- \\"seo\\",\\"0.67\\"
113
- \\"pwa\\",\\"0.33\\"
114
-
115
- category,audit,score,displayValue,description
116
- \\"performance\\",\\"first-contentful-paint\\",\\"0.01\\",\\"6.8 s\\",\\"First Contentful Paint marks the time at which the first text or image is painted. [Learn more about the First Contentful Paint metric](https://developer.chrome.com/docs/lighthouse/performance/first-contentful-paint/).\\"
117
- \\"performance\\",\\"largest-contentful-paint\\",\\"0.01\\",\\"9.3 s\\",\\"Largest Contentful Paint marks the time at which the largest text or image is painted. [Learn more about the Largest Contentful Paint metric](https://developer.chrome.com/docs/lighthouse/performance/lighthouse-largest-contentful-paint/)\\"
118
- \\"performance\\",\\"total-blocking-time\\",\\"0.2\\",\\"1,220 ms\\",\\"Sum of all time periods between FCP and Time to Interactive, when task length exceeded 50ms, expressed in milliseconds. [Learn more about the Total Blocking Time metric](https://developer.chrome.com/docs/lighthouse/performance/lighthouse-total-blocking-time/).\\"
119
- \\"performance\\",\\"cumulative-layout-shift\\",\\"0.8\\",\\"0.136\\",\\"Cumulative Layout Shift measures the movement of visible elements within the viewport. [Learn more about the Cumulative Layout Shift metric](https://web.dev/cls/).\\"
120
- "
121
- `);
122
-
123
- try {
124
- await csvValidator(path);
125
- } catch (err) {
126
- assert.fail('CSV parser error:\n' + err.join('\n'));
127
- } finally {
128
- fs.unlinkSync(path);
129
- }
130
- });
131
-
132
- it('creates CSV for results including categories', () => {
133
- const csvOutput = ReportGenerator.generateReport(sampleResults, 'csv');
134
- expect(csvOutput).toContain('performance');
135
- expect(csvOutput).toContain('accessibility');
136
- expect(csvOutput).toContain('best-practices');
137
- expect(csvOutput).toContain('seo');
138
- expect(csvOutput).toContain('pwa');
139
- });
140
-
141
- it('throws when creating CSV for flow result', () => {
142
- expect(() => {
143
- ReportGenerator.generateReport(sampleFlowResult, 'csv');
144
- }).toThrow('CSV output is not support for user flows');
145
- });
146
-
147
- it('writes extended info', () => {
148
- const htmlOutput = ReportGenerator.generateReport(sampleResults, 'html');
149
- const outputCheck = new RegExp('dobetterweb/dbw_tester.css', 'i');
150
- assert.ok(outputCheck.test(htmlOutput));
151
- });
152
- });
153
-
154
- it('handles array of outputs', () => {
155
- const [json, html] = ReportGenerator.generateReport(sampleResults, ['json', 'html']);
156
- assert.doesNotThrow(_ => JSON.parse(json));
157
- assert.ok(/<!doctype/gim.test(html));
158
- assert.ok(/<html lang="en"/gim.test(html));
159
- });
160
- });
@@ -1,15 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`ReportRendererAxe with aXe renders without axe violations 1`] = `
4
- Array [
5
- Object {
6
- "id": "duplicate-id",
7
- "message": "Fix any of the following:
8
- Document has multiple static elements with the same id attribute: viewport
9
- Fix any of the following:
10
- Document has multiple static elements with the same id attribute: image-alt
11
- Fix any of the following:
12
- Document has multiple static elements with the same id attribute: document-title",
13
- },
14
- ]
15
- `;