lighthouse 9.5.0-dev.20220628 → 9.5.0-dev.20220701

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 (84) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/dist/report/bundle.esm.js +7 -6
  3. package/dist/report/flow.js +24 -24
  4. package/dist/report/standalone.js +19 -19
  5. package/{eslint-local-rules.js → eslint-local-rules.cjs} +0 -0
  6. package/flow-report/test/common-test.tsx +5 -4
  7. package/flow-report/test/flow-report-pptr-test.ts +4 -7
  8. package/flow-report/test/run-flow-report-tests.sh +20 -0
  9. package/flow-report/test/setup/env-setup.ts +44 -24
  10. package/flow-report/test/sidebar/sidebar-test.tsx +0 -1
  11. package/flow-report/test/topbar-test.tsx +5 -5
  12. package/flow-report/test/util-test.tsx +3 -3
  13. package/flow-report/tsconfig.json +4 -1
  14. package/lighthouse-cli/cli-flags.js +313 -305
  15. package/lighthouse-cli/run.js +1 -1
  16. package/lighthouse-cli/test/smokehouse/report-assert-test.js +1 -1
  17. package/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +30 -5
  18. package/lighthouse-core/audits/final-screenshot.js +2 -2
  19. package/lighthouse-core/audits/screenshot-thumbnails.js +6 -6
  20. package/lighthouse-core/audits/work-during-interaction.js +3 -3
  21. package/lighthouse-core/computed/metrics/cumulative-layout-shift.js +3 -3
  22. package/lighthouse-core/computed/metrics/first-meaningful-paint.js +2 -2
  23. package/lighthouse-core/computed/metrics/interactive.js +5 -5
  24. package/lighthouse-core/computed/metrics/lantern-first-meaningful-paint.js +3 -3
  25. package/lighthouse-core/computed/metrics/lantern-largest-contentful-paint.js +3 -3
  26. package/lighthouse-core/computed/metrics/largest-contentful-paint-all-frames.js +2 -2
  27. package/lighthouse-core/computed/metrics/largest-contentful-paint.js +2 -2
  28. package/lighthouse-core/computed/speedline.js +4 -4
  29. package/lighthouse-core/config/config-plugin.js +26 -0
  30. package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +1 -0
  31. package/lighthouse-core/fraggle-rock/gather/session.js +3 -2
  32. package/lighthouse-core/gather/connections/connection.js +2 -2
  33. package/lighthouse-core/gather/driver/wait-for-condition.js +3 -3
  34. package/lighthouse-core/gather/driver.js +3 -2
  35. package/lighthouse-core/gather/gather-runner.js +2 -1
  36. package/lighthouse-core/gather/gatherers/main-document-content.js +0 -2
  37. package/lighthouse-core/lib/asset-saver.js +6 -6
  38. package/lighthouse-core/lib/lh-env.js +1 -1
  39. package/lighthouse-core/lib/lh-error.js +5 -5
  40. package/lighthouse-core/lib/lh-trace-processor.js +6 -6
  41. package/lighthouse-core/lib/navigation-error.js +34 -14
  42. package/lighthouse-core/lib/sentry.js +3 -3
  43. package/lighthouse-core/lib/url-shim.js +2 -2
  44. package/lighthouse-core/runner.js +6 -4
  45. package/lighthouse-core/util-commonjs.js +7 -6
  46. package/package.json +24 -19
  47. package/report/renderer/util.js +7 -6
  48. package/report/test/clients/bundle-test.js +4 -4
  49. package/report/test/generator/report-generator-test.js +3 -1
  50. package/report/test/renderer/category-renderer-test.js +3 -3
  51. package/report/test/renderer/components-test.js +36 -34
  52. package/report/test/renderer/crc-details-renderer-test.js +2 -2
  53. package/report/test/renderer/details-renderer-test.js +2 -2
  54. package/report/test/renderer/dom-test.js +4 -4
  55. package/report/test/renderer/element-screenshot-renderer-test.js +3 -2
  56. package/report/test/renderer/performance-category-renderer-test.js +4 -4
  57. package/report/test/renderer/pwa-category-renderer-test.js +3 -3
  58. package/report/test/renderer/report-renderer-axe-test.js +6 -8
  59. package/report/test/renderer/report-renderer-test.js +5 -5
  60. package/report/test/renderer/report-ui-features-test.js +8 -8
  61. package/report/test/renderer/snippet-renderer-test.js +2 -2
  62. package/report/test/renderer/text-encoding-test.js +2 -2
  63. package/report/test/renderer/util-test.js +1 -1
  64. package/root.js +0 -18
  65. package/shared/localization/format.js +1 -1
  66. package/shared/localization/locales/en-US.json +3 -0
  67. package/shared/localization/locales/en-XL.json +3 -0
  68. package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +1 -1
  69. package/third-party/chromium-synchronization/installability-errors-test.js +1 -3
  70. package/third-party/devtools-tests/README.md +2 -2
  71. package/third-party/devtools-tests/e2e/lighthouse/BUILD.gn +17 -0
  72. package/third-party/devtools-tests/e2e/resources/lighthouse/BUILD.gn +9 -0
  73. package/tsconfig.json +1 -1
  74. package/types/global-lh.d.ts +2 -2
  75. package/types/test.d.ts +53 -0
  76. package/flow-report/.eslintrc.cjs +0 -51
  77. package/flow-report/jest.config.js +0 -24
  78. package/flow-report/test/setup/global-setup.ts +0 -11
  79. package/jest.config.js +0 -30
  80. package/lighthouse-cli/.eslintrc.cjs +0 -28
  81. package/report/.eslintrc.cjs +0 -37
  82. package/report/test/.eslintrc.cjs +0 -11
  83. package/shared/test/localization/.eslintrc.cjs +0 -11
  84. package/types/jest.d.ts +0 -25
@@ -14,7 +14,7 @@ import URL from '../../../lighthouse-core/lib/url-shim.js';
14
14
  import {DOM} from '../../renderer/dom.js';
15
15
  import {DetailsRenderer} from '../../renderer/details-renderer.js';
16
16
  import {PerformanceCategoryRenderer} from '../../renderer/performance-category-renderer.js';
17
- import {readJson} from '../../../root.js';
17
+ import {readJson} from '../../../lighthouse-core/test/test-utils.js';
18
18
 
19
19
  const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
20
20
 
@@ -23,7 +23,7 @@ describe('PerfCategoryRenderer', () => {
23
23
  let renderer;
24
24
  let sampleResults;
25
25
 
26
- beforeAll(() => {
26
+ before(() => {
27
27
  Util.i18n = new I18n('en', {...Util.UIStrings});
28
28
 
29
29
  const {document} = new jsdom.JSDOM().window;
@@ -36,7 +36,7 @@ describe('PerfCategoryRenderer', () => {
36
36
  category = sampleResults.categories.performance;
37
37
  });
38
38
 
39
- afterAll(() => {
39
+ after(() => {
40
40
  Util.i18n = undefined;
41
41
  });
42
42
 
@@ -390,7 +390,7 @@ Array [
390
390
  let getDescriptionsAfterCheckedToggle;
391
391
 
392
392
  describe('works if there is a performance category', () => {
393
- beforeAll(() => {
393
+ before(() => {
394
394
  container = renderer.render(category, sampleResults.categoryGroups);
395
395
  const metricsAuditGroup = container.querySelector(metricsSelector);
396
396
  toggle = metricsAuditGroup.querySelector(toggleSelector);
@@ -13,7 +13,7 @@ import {I18n} from '../../renderer/i18n.js';
13
13
  import {DOM} from '../../renderer/dom.js';
14
14
  import {DetailsRenderer} from '../../renderer/details-renderer.js';
15
15
  import {PwaCategoryRenderer} from '../../renderer/pwa-category-renderer.js';
16
- import {readJson} from '../../../root.js';
16
+ import {readJson} from '../../../lighthouse-core/test/test-utils.js';
17
17
 
18
18
  const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
19
19
 
@@ -22,7 +22,7 @@ describe('PwaCategoryRenderer', () => {
22
22
  let pwaRenderer;
23
23
  let sampleResults;
24
24
 
25
- beforeAll(() => {
25
+ before(() => {
26
26
  Util.i18n = new I18n('en', {...Util.UIStrings});
27
27
 
28
28
  const {document} = new jsdom.JSDOM().window;
@@ -39,7 +39,7 @@ describe('PwaCategoryRenderer', () => {
39
39
  category = JSON.parse(JSON.stringify(pwaCategory));
40
40
  });
41
41
 
42
- afterAll(() => {
42
+ after(() => {
43
43
  Util.i18n = undefined;
44
44
  });
45
45
 
@@ -8,7 +8,7 @@ import puppeteer from 'puppeteer';
8
8
 
9
9
  import reportGenerator from '../../generator/report-generator.js';
10
10
  import axeLib from '../../../lighthouse-core/lib/axe.js';
11
- import {readJson} from '../../../root.js';
11
+ import {readJson} from '../../../lighthouse-core/test/test-utils.js';
12
12
 
13
13
  const sampleResults = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
14
14
 
@@ -16,14 +16,16 @@ describe('ReportRendererAxe', () => {
16
16
  describe('with aXe', () => {
17
17
  let browser;
18
18
 
19
- beforeAll(async () => {
19
+ before(async () => {
20
20
  browser = await puppeteer.launch();
21
21
  });
22
22
 
23
- afterAll(async () => {
23
+ after(async () => {
24
24
  await browser.close();
25
25
  });
26
26
 
27
+ // This test takes 10s on fast hardware, but can take longer in CI.
28
+ // https://github.com/dequelabs/axe-core/tree/b573b1c1/doc/examples/jest_react#timeout-issues
27
29
  it('renders without axe violations', async () => {
28
30
  const page = await browser.newPage();
29
31
  const htmlReport = reportGenerator.generateReportHtml(sampleResults);
@@ -78,10 +80,6 @@ describe('ReportRendererAxe', () => {
78
80
  };
79
81
  });
80
82
  expect(axeSummary).toMatchSnapshot();
81
- },
82
- // This test takes 10s on fast hardware, but can take longer in CI.
83
- // https://github.com/dequelabs/axe-core/tree/b573b1c1/doc/examples/jest_react#timeout-issues
84
- /* timeout= */ 20_000
85
- );
83
+ });
86
84
  });
87
85
  });
@@ -7,7 +7,7 @@
7
7
  import {strict as assert} from 'assert';
8
8
 
9
9
  import jsdom from 'jsdom';
10
- import {jest} from '@jest/globals';
10
+ import jestMock from 'jest-mock';
11
11
 
12
12
  import {Util} from '../../renderer/util.js';
13
13
  import URL from '../../../lighthouse-core/lib/url-shim.js';
@@ -15,7 +15,7 @@ import {DOM} from '../../renderer/dom.js';
15
15
  import {DetailsRenderer} from '../../renderer/details-renderer.js';
16
16
  import {CategoryRenderer} from '../../renderer/category-renderer.js';
17
17
  import {ReportRenderer} from '../../renderer/report-renderer.js';
18
- import {readJson} from '../../../root.js';
18
+ import {readJson} from '../../../lighthouse-core/test/test-utils.js';
19
19
 
20
20
  const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
21
21
 
@@ -25,8 +25,8 @@ describe('ReportRenderer', () => {
25
25
  let renderer;
26
26
  let sampleResults;
27
27
 
28
- beforeAll(() => {
29
- global.console.warn = jest.fn();
28
+ before(() => {
29
+ global.console.warn = jestMock.fn();
30
30
 
31
31
  // Stub out matchMedia for Node.
32
32
  global.matchMedia = function() {
@@ -45,7 +45,7 @@ describe('ReportRenderer', () => {
45
45
  sampleResults = Util.prepareReportResult(sampleResultsOrig);
46
46
  });
47
47
 
48
- afterAll(() => {
48
+ after(() => {
49
49
  global.self = undefined;
50
50
  global.matchMedia = undefined;
51
51
  });
@@ -7,7 +7,7 @@
7
7
  import {strict as assert} from 'assert';
8
8
 
9
9
  import jsdom from 'jsdom';
10
- import {jest} from '@jest/globals';
10
+ import jestMock from 'jest-mock';
11
11
 
12
12
  import reportAssets from '../../generator/report-assets.js';
13
13
  import {Util} from '../../renderer/util.js';
@@ -16,7 +16,7 @@ import {DetailsRenderer} from '../../renderer/details-renderer.js';
16
16
  import {ReportUIFeatures} from '../../renderer/report-ui-features.js';
17
17
  import {CategoryRenderer} from '../../renderer/category-renderer.js';
18
18
  import {ReportRenderer} from '../../renderer/report-renderer.js';
19
- import {readJson} from '../../../root.js';
19
+ import {readJson} from '../../../lighthouse-core/test/test-utils.js';
20
20
 
21
21
  const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
22
22
 
@@ -40,8 +40,8 @@ describe('ReportUIFeatures', () => {
40
40
  return container;
41
41
  }
42
42
 
43
- beforeAll(() => {
44
- global.console.warn = jest.fn();
43
+ before(() => {
44
+ global.console.warn = jestMock.fn();
45
45
 
46
46
  // Stub out matchMedia for Node.
47
47
  global.matchMedia = function() {
@@ -80,7 +80,7 @@ describe('ReportUIFeatures', () => {
80
80
  render(sampleResults);
81
81
  });
82
82
 
83
- afterAll(() => {
83
+ after(() => {
84
84
  global.window = undefined;
85
85
  global.HTMLElement = undefined;
86
86
  global.HTMLInputElement = undefined;
@@ -105,7 +105,7 @@ describe('ReportUIFeatures', () => {
105
105
  describe('third-party filtering', () => {
106
106
  let container;
107
107
 
108
- beforeAll(() => {
108
+ before(() => {
109
109
  const lhr = JSON.parse(JSON.stringify(sampleResults));
110
110
  lhr.requestedUrl = lhr.finalUrl = 'http://www.example.com';
111
111
  const webpAuditItemTemplate = {
@@ -283,7 +283,7 @@ describe('ReportUIFeatures', () => {
283
283
  const getSaveEl = () => dom.find('a[data-action="save-html"]', container);
284
284
  expect(getSaveEl().classList.contains('lh-hidden')).toBeTruthy();
285
285
 
286
- const getHtmlMock = jest.fn();
286
+ const getHtmlMock = jestMock.fn();
287
287
  container = render(sampleResults, {
288
288
  getStandaloneReportHTML: getHtmlMock,
289
289
  });
@@ -428,7 +428,7 @@ describe('ReportUIFeatures', () => {
428
428
  describe('_getNextSelectableNode', () => {
429
429
  let createDiv;
430
430
 
431
- beforeAll(() => {
431
+ before(() => {
432
432
  createDiv = () => dom.document().createElement('div');
433
433
  });
434
434
 
@@ -54,13 +54,13 @@ function makeSnippetDetails({
54
54
  describe('DetailsRenderer', () => {
55
55
  let dom;
56
56
 
57
- beforeAll(() => {
57
+ before(() => {
58
58
  Util.i18n = new I18n('en', {...Util.UIStrings});
59
59
  const {document} = new jsdom.JSDOM().window;
60
60
  dom = new DOM(document);
61
61
  });
62
62
 
63
- afterAll(() => {
63
+ after(() => {
64
64
  Util.i18n = undefined;
65
65
  });
66
66
 
@@ -12,11 +12,11 @@ import {TextEncoding} from '../../renderer/text-encoding.js';
12
12
  import {LH_ROOT} from '../../../root.js';
13
13
 
14
14
  describe('TextEncoding', () => {
15
- beforeAll(() => {
15
+ before(() => {
16
16
  global.window = {pako};
17
17
  });
18
18
 
19
- afterAll(() => {
19
+ after(() => {
20
20
  global.window = undefined;
21
21
  });
22
22
 
@@ -8,7 +8,7 @@ import {strict as assert} from 'assert';
8
8
 
9
9
  import {Util} from '../../renderer/util.js';
10
10
  import {I18n} from '../../renderer/i18n.js';
11
- import {readJson} from '../../../root.js';
11
+ import {readJson} from '../../../lighthouse-core/test/test-utils.js';
12
12
 
13
13
  const sampleResult = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta);
14
14
 
package/root.js CHANGED
@@ -5,24 +5,6 @@
5
5
  */
6
6
  'use strict';
7
7
 
8
- const fs = require('fs');
9
- const path = require('path');
10
- const url = require('url');
11
-
12
- // import {dirname} from 'path';
13
- // import {fileURLToPath} from 'url';
14
-
15
8
  module.exports = {
16
9
  LH_ROOT: __dirname,
17
- /**
18
- * Return parsed json object.
19
- * Resolves path relative to importMeta.url (if provided) or LH_ROOT (if not provided).
20
- * @param {string} filePath Can be an absolute or relative path.
21
- * @param {ImportMeta=} importMeta
22
- */
23
- readJson(filePath, importMeta) {
24
- const dir = importMeta ? path.dirname(url.fileURLToPath(importMeta.url)) : __dirname;
25
- filePath = path.resolve(dir, filePath);
26
- return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
27
- },
28
10
  };
@@ -147,7 +147,7 @@ function _preformatValues(messageFormatter, values = {}, lhlMessage) {
147
147
  for (const valueId of Object.keys(values)) {
148
148
  if (valueId in formattedValues) continue;
149
149
 
150
- // errorCode is a special case always allowed to help LHError ease-of-use.
150
+ // errorCode is a special case always allowed to help LighthouseError ease-of-use.
151
151
  if (valueId === 'errorCode') {
152
152
  formattedValues.errorCode = values.errorCode;
153
153
  continue;
@@ -2102,6 +2102,9 @@
2102
2102
  "lighthouse-core/lib/lh-error.js | urlInvalid": {
2103
2103
  "message": "The URL you have provided appears to be invalid."
2104
2104
  },
2105
+ "lighthouse-core/lib/navigation-error.js | warningXhtml": {
2106
+ "message": "The page MIME type is XHTML: Lighthouse does not explicitly support this document type"
2107
+ },
2105
2108
  "node_modules/lighthouse-stack-packs/packs/amp.js | efficient-animated-content": {
2106
2109
  "message": "For animated content, use [`amp-anim`](https://amp.dev/documentation/components/amp-anim/) to minimize CPU usage when the content is offscreen."
2107
2110
  },
@@ -2102,6 +2102,9 @@
2102
2102
  "lighthouse-core/lib/lh-error.js | urlInvalid": {
2103
2103
  "message": "T̂h́ê ÚR̂Ĺ ŷóû h́âv́ê ṕr̂óv̂íd̂éd̂ áp̂ṕêár̂ś t̂ó b̂é îńv̂ál̂íd̂."
2104
2104
  },
2105
+ "lighthouse-core/lib/navigation-error.js | warningXhtml": {
2106
+ "message": "T̂h́ê ṕâǵê ḾÎḾÊ t́ŷṕê íŝ X́ĤT́M̂Ĺ: L̂íĝh́t̂h́ôúŝé d̂óêś n̂ót̂ éx̂ṕl̂íĉít̂ĺŷ śûṕp̂ór̂t́ t̂h́îś d̂óĉúm̂én̂t́ t̂ýp̂é"
2107
+ },
2105
2108
  "node_modules/lighthouse-stack-packs/packs/amp.js | efficient-animated-content": {
2106
2109
  "message": "F̂ór̂ án̂ím̂át̂éd̂ ćôńt̂én̂t́, ûśê [`amp-anim`](https://amp.dev/documentation/components/amp-anim/) t́ô ḿîńîḿîźê ĆP̂Ú ûśâǵê ẃĥén̂ t́ĥé ĉón̂t́êńt̂ íŝ óf̂f́ŝćr̂éêń."
2107
2110
  },
@@ -17,7 +17,7 @@ describe('issueAdded types', () => {
17
17
  /** @type {Array<LH.Crdp.Audits.InspectorIssueDetails>} */
18
18
  let inspectorIssueDetailsTypes;
19
19
 
20
- beforeAll(async () => {
20
+ before(async () => {
21
21
  const browserProtocolUrl =
22
22
  'https://raw.githubusercontent.com/ChromeDevTools/devtools-protocol/master/json/browser_protocol.json';
23
23
  const json = await fetch(browserProtocolUrl).then(r => r.json());
@@ -9,12 +9,10 @@ const fetch = require('node-fetch');
9
9
 
10
10
  const InstallableManifestAudit = require('../../lighthouse-core/audits/installable-manifest.js');
11
11
 
12
- jest.setTimeout(20_000);
13
-
14
12
  describe('installabilityErrors', () => {
15
13
  let chromiumErrorIds;
16
14
 
17
- beforeAll(async () => {
15
+ before(async () => {
18
16
  const installableLoggingGitTilesUrl =
19
17
  'https://chromium.googlesource.com/chromium/src/+/main/components/webapps/browser/installable/installable_logging.cc?format=TEXT';
20
18
  const resp = await fetch(installableLoggingGitTilesUrl);
@@ -9,6 +9,6 @@ See `lighthouse-core/test/chromium-web-tests/README.md` for more.
9
9
  ## Sync
10
10
 
11
11
  ```sh
12
- rsync -ahvz --exclude='OWNERS' --exclude='BUILD.gn' ~/src/devtools/devtools-frontend/test/e2e/lighthouse/ third-party/devtools-tests/e2e/lighthouse/
13
- rsync -ahvz --exclude='OWNERS' --exclude='BUILD.gn' ~/src/devtools/devtools-frontend/test/e2e/resources/lighthouse/ third-party/devtools-tests/e2e/resources/lighthouse/
12
+ rsync -ahvz --exclude='OWNERS' ~/src/devtools/devtools-frontend/test/e2e/lighthouse/ third-party/devtools-tests/e2e/lighthouse/
13
+ rsync -ahvz --exclude='OWNERS' ~/src/devtools/devtools-frontend/test/e2e/resources/lighthouse/ third-party/devtools-tests/e2e/resources/lighthouse/
14
14
  ```
@@ -0,0 +1,17 @@
1
+ # Copyright 2020 The Chromium Authors. All rights reserved.
2
+ # Use of this source code is governed by a BSD-style license that can be
3
+ # found in the LICENSE file.
4
+
5
+ import("../../../third_party/typescript/typescript.gni")
6
+
7
+ node_ts_library("lighthouse") {
8
+ sources = [
9
+ "generate-report_test.ts",
10
+ "indexeddb-warning_test.ts",
11
+ ]
12
+
13
+ deps = [
14
+ "../../shared",
15
+ "../helpers",
16
+ ]
17
+ }
@@ -0,0 +1,9 @@
1
+ # Copyright 2022 The Chromium Authors. All rights reserved.
2
+ # Use of this source code is governed by a BSD-style license that can be
3
+ # found in the LICENSE file.
4
+
5
+ import("../../../../scripts/build/ninja/copy.gni")
6
+
7
+ copy_to_gen("lighthouse") {
8
+ sources = [ "lighthouse-storage.html" ]
9
+ }
package/tsconfig.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "clients/**/*.js",
19
19
  "build/**/*.js",
20
20
  "./types/**/*.d.ts",
21
- "eslint-local-rules.js",
21
+ "eslint-local-rules.cjs",
22
22
  "third-party/axe/valid-langs.js",
23
23
 
24
24
  // TODO(esmodules): JSON files included via resolveJsonModule. Removable on the switch to ES Modules.
@@ -14,7 +14,7 @@ import _CrdpMappings from 'devtools-protocol/types/protocol-mapping';
14
14
  import * as Externs from './externs';
15
15
  import Gatherer_ from './gatherer';
16
16
  import * as I18n from './lhr/i18n';
17
- import LHError = require('../lighthouse-core/lib/lh-error.js');
17
+ import LighthouseError_ = require('../lighthouse-core/lib/lh-error.js');
18
18
  import LHResult from './lhr/lhr';
19
19
  import FlowResult_ from './lhr/flow';
20
20
  import Protocol_ from './protocol';
@@ -59,7 +59,7 @@ declare global {
59
59
  export import DevToolsJsonTarget = Externs.DevToolsJsonTarget;
60
60
 
61
61
  export import Gatherer = Gatherer_;
62
- export import LighthouseError = LHError;
62
+ export import LighthouseError = LighthouseError_;
63
63
  export import Result = LHResult;
64
64
  export import FlowResult = FlowResult_;
65
65
 
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @license Copyright 2022 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
+
7
+ declare global {
8
+ var expect: import('expect').Expect;
9
+ type Mock<T, Y> = import('jest-mock').Mock<T, Y>;
10
+ }
11
+
12
+ declare module 'expect' {
13
+ interface Matchers<R extends void | Promise<void>, T={}> {
14
+ /**
15
+ * This ensures that a value matches the most recent snapshot with property matchers.
16
+ * Check out [the Snapshot Testing guide](http://facebook.github.io/jest/docs/snapshot-testing.html) for more information.
17
+ */
18
+ // tslint:disable-next-line: no-unnecessary-generics
19
+ toMatchSnapshot<U extends { [P in keyof T]: any }>(propertyMatchers: Partial<U>, snapshotName?: string): R;
20
+ /**
21
+ * This ensures that a value matches the most recent snapshot.
22
+ * Check out [the Snapshot Testing guide](http://facebook.github.io/jest/docs/snapshot-testing.html) for more information.
23
+ */
24
+ toMatchSnapshot(snapshotName?: string): R;
25
+ /**
26
+ * This ensures that a value matches the most recent snapshot with property matchers.
27
+ * Instead of writing the snapshot value to a .snap file, it will be written into the source code automatically.
28
+ * Check out [the Snapshot Testing guide](http://facebook.github.io/jest/docs/snapshot-testing.html) for more information.
29
+ */
30
+ // tslint:disable-next-line: no-unnecessary-generics
31
+ toMatchInlineSnapshot<U extends { [P in keyof T]: any }>(propertyMatchers: Partial<U>, snapshot?: string): R;
32
+
33
+ // The following are custom matchers defined in expect-setup.js
34
+
35
+ /**
36
+ * Jest's `toBeCloseTo()` exposed as an asymmetric matcher. This allows
37
+ * approximate numeric testing within matchers like `toMatchObject()`.
38
+ * The default for `numDigits` is 2.
39
+ */
40
+ toBeApproximately(expected: number, numDigits?: number): R;
41
+ /**
42
+ * Asserts that an inspectable promise created by makePromiseInspectable is currently resolved or rejected.
43
+ * This is useful for situations where we want to test that we are actually waiting for a particular event.
44
+ */
45
+ toBeDone: (failureMessage?: string) => R;
46
+ /**
47
+ * Asserts that an i18n string (using en-US) matches an expected pattern.
48
+ */
49
+ toBeDisplayString: (pattern: RegExp | string) => R;
50
+ }
51
+ }
52
+
53
+ export {};
@@ -1,51 +0,0 @@
1
- /**
2
- * @license Copyright 2021 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
-
7
- module.exports = {
8
- extends: '../.eslintrc.js',
9
- env: {
10
- node: true,
11
- browser: true,
12
- },
13
- plugins: [
14
- '@typescript-eslint',
15
- ],
16
- rules: {
17
- // TODO(esmodules): move to root eslint when all code is ESM
18
- // or when this is resolved: https://github.com/import-js/eslint-plugin-import/issues/2214
19
- 'import/order': [2, {
20
- 'groups': [
21
- 'builtin',
22
- 'external',
23
- ['sibling', 'parent'],
24
- 'index',
25
- 'object',
26
- 'type',
27
- ],
28
- 'newlines-between': 'always',
29
- }],
30
- 'import/group-exports': 2,
31
- 'import/exports-last': 2,
32
- '@typescript-eslint/type-annotation-spacing': 2,
33
- },
34
- overrides: [
35
- // TS already handles this issue.
36
- // https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
37
- {
38
- files: ['**/*.ts', '**/*.tsx', '**/*.js'],
39
- rules: {
40
- 'no-undef': 'off',
41
- },
42
- },
43
- ],
44
- parserOptions: {
45
- ecmaVersion: 2019,
46
- ecmaFeatures: {
47
- jsx: true,
48
- },
49
- sourceType: 'module',
50
- },
51
- };
@@ -1,24 +0,0 @@
1
- /**
2
- * @license Copyright 2021 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
-
7
- export default {
8
- testEnvironment: 'node',
9
- preset: 'ts-jest',
10
- globalSetup: './test/setup/global-setup.ts',
11
- setupFilesAfterEnv: [
12
- './test/setup/env-setup.ts',
13
- ],
14
- testMatch: [
15
- '**/test/**/*-test.ts',
16
- '**/test/**/*-test.tsx',
17
- ],
18
- extensionsToTreatAsEsm: ['.ts', '.tsx'],
19
- globals: {
20
- 'ts-jest': {
21
- useESM: true,
22
- },
23
- },
24
- };
@@ -1,11 +0,0 @@
1
- /**
2
- * @license Copyright 2021 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
-
7
- export default async () => {
8
- // Use consistent TZ across testing environments.
9
- // Timezone is used to construct date strings.
10
- process.env.TZ = 'UTC';
11
- };
package/jest.config.js DELETED
@@ -1,30 +0,0 @@
1
- /**
2
- * @license Copyright 2018 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
- module.exports = {
9
- setupFilesAfterEnv: ['./lighthouse-core/test/jest-setup/setup.js'],
10
- testEnvironment: 'node',
11
- testMatch: [
12
- '**/lighthouse-core/**/*-test.js',
13
- '**/lighthouse-cli/**/*-test.js',
14
- '**/report/**/*-test.js',
15
- '**/lighthouse-core/test/fraggle-rock/**/*-test-pptr.js',
16
- '**/treemap/**/*-test.js',
17
- '**/viewer/**/*-test.js',
18
- '**/third-party/**/*-test.js',
19
- '**/clients/test/**/*-test.js',
20
- '**/shared/**/*-test.js',
21
- '**/build/**/*-test.js',
22
- ],
23
- modulePathIgnorePatterns: ['<rootDir>/.tmp'],
24
- transform: {},
25
- prettierPath: null,
26
- projects: [
27
- '<rootDir>',
28
- '<rootDir>/flow-report',
29
- ],
30
- };
@@ -1,28 +0,0 @@
1
- /**
2
- * @license Copyright 2021 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
-
7
- module.exports = {
8
- rules: {
9
- // TODO(esmodules): move to root eslint when all code is ESM
10
- // or when this is resolved: https://github.com/import-js/eslint-plugin-import/issues/2214
11
- 'import/order': [2, {
12
- 'groups': [
13
- 'builtin',
14
- 'external',
15
- ['sibling', 'parent'],
16
- 'index',
17
- 'object',
18
- 'type',
19
- ],
20
- 'newlines-between': 'always',
21
- }],
22
- 'import/group-exports': 2,
23
- 'import/exports-last': 2,
24
- },
25
- parserOptions: {
26
- sourceType: 'module',
27
- },
28
- };
@@ -1,37 +0,0 @@
1
- /**
2
- * @license Copyright 2021 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
-
7
- /**
8
- * eslint does not support ESM rc files, so this must be a .cjs file.
9
- * @see https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats
10
- * @see https://github.com/eslint/eslint/issues/13481
11
- */
12
-
13
- module.exports = {
14
- env: {
15
- browser: true,
16
- },
17
- rules: {
18
- // TODO(esmodules): move to root eslint when all code is ESM
19
- // or when this is resolved: https://github.com/import-js/eslint-plugin-import/issues/2214
20
- 'import/order': [2, {
21
- 'groups': [
22
- 'builtin',
23
- 'external',
24
- ['sibling', 'parent'],
25
- 'index',
26
- 'object',
27
- 'type',
28
- ],
29
- 'newlines-between': 'always',
30
- }],
31
- 'import/group-exports': 2,
32
- 'import/exports-last': 2,
33
- },
34
- parserOptions: {
35
- sourceType: 'module',
36
- },
37
- };