From 94b4f38d53694d6fdec38a12481f5dbd6a856f08 Mon Sep 17 00:00:00 2001 From: Connor Clark Date: Mon, 23 May 2022 18:24:09 -0700 Subject: [PATCH] tests: use readJson instead of imports for json (#14020) --- .eslintrc.js | 1 + lighthouse-cli/test/cli/printer-test.js | 4 ++- .../test/audits/bootup-time-test.js | 8 ++++-- .../byte-efficiency-audit-test.js | 10 ++++--- .../duplicated-javascript-test.js | 6 ++-- .../render-blocking-resources-test.js | 10 ++++--- .../audits/critical-request-chains-test.js | 4 ++- .../test/audits/diagnostics-test.js | 6 ++-- .../audits/dobetterweb/uses-http2-test.js | 6 ++-- .../test/audits/final-screenshot-test.js | 4 ++- .../test/audits/installable-manifest-test.js | 6 ++-- .../test/audits/main-thread-tasks-test.js | 4 ++- .../audits/mainthread-work-breakdown-test.js | 10 ++++--- .../test/audits/maskable-icon-test.js | 6 ++-- lighthouse-core/test/audits/metrics-test.js | 22 ++++++++------- .../metrics/cumulative-layout-shift-test.js | 4 ++- ...rimental-interaction-to-next-paint-test.js | 6 ++-- .../metrics/first-contentful-paint-3g-test.js | 6 ++-- .../metrics/first-contentful-paint-test.js | 10 ++++--- .../metrics/first-meaningful-paint-test.js | 6 ++-- .../test/audits/metrics/interactive-test.js | 10 ++++--- .../metrics/largest-contentful-paint-test.js | 10 ++++--- .../test/audits/metrics/speed-index-test.js | 6 ++-- .../metrics/total-blocking-time-test.js | 10 ++++--- .../test/audits/network-requests-test.js | 5 +++- .../test/audits/network-rtt-test.js | 4 ++- .../audits/network-server-latency-test.js | 4 ++- .../test/audits/predictive-perf-test.js | 7 +++-- .../test/audits/screenshot-thumbnails-test.js | 7 +++-- .../test/audits/splash-screen-test.js | 6 ++-- .../test/audits/themed-omnibox-test.js | 4 ++- .../test/audits/third-party-facades-test.js | 12 ++++---- .../test/audits/third-party-summary-test.js | 9 ++++-- .../test/audits/timing-budget-test.js | 10 ++++--- .../test/audits/user-timing-test.js | 4 ++- .../test/audits/uses-rel-preload-test.js | 6 ++-- .../audits/work-during-interaction-test.js | 6 ++-- .../computed/critical-request-chains-test.js | 4 ++- .../test/computed/load-simulator-test.js | 4 ++- .../test/computed/main-resource-test.js | 4 ++- .../test/computed/main-thread-tasks-test.js | 4 ++- .../test/computed/manifest-values-test.js | 4 ++- .../metrics/cumulative-layout-shift-test.js | 10 ++++--- .../first-contentful-paint-all-frames-test.js | 6 ++-- .../metrics/first-contentful-paint-test.js | 6 ++-- .../metrics/first-meaningful-paint-test.js | 14 ++++++---- .../test/computed/metrics/interactive-test.js | 6 ++-- .../lantern-first-contentful-paint-test.js | 7 +++-- .../lantern-first-meaningful-paint-test.js | 6 ++-- .../metrics/lantern-interactive-test.js | 10 ++++--- .../lantern-largest-contentful-paint-test.js | 6 ++-- .../metrics/lantern-speed-index-test.js | 6 ++-- ...argest-contentful-paint-all-frames-test.js | 14 ++++++---- .../metrics/largest-contentful-paint-test.js | 10 ++++--- .../metrics/max-potential-fid-test.js | 6 ++-- .../computed/metrics/responsiveness-test.js | 6 ++-- .../test/computed/metrics/speed-index-test.js | 10 ++++--- .../computed/metrics/timing-summary-test.js | 7 +++-- .../metrics/total-blocking-time-test.js | 6 ++-- .../test/computed/network-analysis-test.js | 4 ++- .../computed/page-dependency-graph-test.js | 6 ++-- .../computed/processed-navigation-test.js | 8 ++++-- .../test/computed/processed-trace-test.js | 4 ++- .../test/computed/screenshots-test.js | 4 ++- .../test/computed/speedline-test.js | 5 ++-- .../test/computed/trace-of-tab-test.js | 4 ++- .../test/gather/gather-runner-test.js | 4 ++- .../gather/gatherers/image-elements-test.js | 6 ++-- .../gatherers/main-document-content-test.js | 8 ++---- .../gatherers/network-user-agent-test.js | 5 ++-- .../gather/gatherers/trace-elements-test.js | 4 ++- lighthouse-core/test/index-test.js | 5 ++-- .../test/lib/arbitrary-equality-map-test.js | 4 ++- lighthouse-core/test/lib/asset-saver-test.js | 12 ++++---- .../simulator/network-analyzer-test.js | 6 ++-- .../simulator/simulator-test.js | 6 ++-- .../test/lib/manifest-parser-test.js | 4 ++- .../test/lib/minify-devtoolslog-test.js | 6 ++-- lighthouse-core/test/lib/minify-trace-test.js | 6 ++-- .../test/lib/network-recorder-test.js | 12 ++++---- .../test/lib/proto-preprocessor-test.js | 4 ++- .../lib/tracehouse/cpu-profile-model-test.js | 4 ++- .../lib/tracehouse/main-thread-tasks-test.js | 6 ++-- .../test/lib/tracehouse/task-summary-test.js | 6 ++-- .../lib/tracehouse/trace-processor-test.js | 28 ++++++++++--------- .../test/lib/traces/pwmetrics-events-test.js | 6 ++-- .../network-records-to-devtools-log-test.js | 4 ++- lighthouse-core/test/sample-json-test.js | 4 ++- .../test/renderer/category-renderer-test.js | 4 ++- .../performance-category-renderer-test.js | 4 ++- .../renderer/pwa-category-renderer-test.js | 4 ++- .../test/renderer/report-renderer-axe-test.js | 4 ++- report/test/renderer/report-renderer-test.js | 4 ++- .../test/renderer/report-ui-features-test.js | 4 ++- report/test/renderer/util-test.js | 4 ++- 95 files changed, 406 insertions(+), 222 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 1407585f36eb..c1b27434b08d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -36,6 +36,7 @@ module.exports = { }], 'no-floating-decimal': 2, 'max-len': [2, 100, { + ignorePattern: 'readJson\\(', ignoreComments: true, ignoreUrls: true, tabWidth: 2, diff --git a/lighthouse-cli/test/cli/printer-test.js b/lighthouse-cli/test/cli/printer-test.js index 0bcfed2651bf..97a3098aa574 100644 --- a/lighthouse-cli/test/cli/printer-test.js +++ b/lighthouse-cli/test/cli/printer-test.js @@ -7,8 +7,10 @@ import {strict as assert} from 'assert'; import fs from 'fs'; +import {readJson} from '../../../root.js'; import * as Printer from '../../printer.js'; -import sampleResults from '../../../lighthouse-core/test/results/sample_v2.json'; + +const sampleResults = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta); describe('Printer', () => { it('accepts valid output paths', () => { diff --git a/lighthouse-core/test/audits/bootup-time-test.js b/lighthouse-core/test/audits/bootup-time-test.js index 7f5bc66809f9..1d39cd1d86d5 100644 --- a/lighthouse-core/test/audits/bootup-time-test.js +++ b/lighthouse-core/test/audits/bootup-time-test.js @@ -6,10 +6,12 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../root.js'; import BootupTime from '../../audits/bootup-time.js'; -import acceptableTrace from '../fixtures/traces/progressive-app-m60.json'; -import acceptableDevtoolsLogs from '../fixtures/traces/progressive-app-m60.devtools.log.json'; -import errorTrace from '../fixtures/traces/no_fmp_event.json'; + +const acceptableTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); +const acceptableDevtoolsLogs = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); +const errorTrace = readJson('../fixtures/traces/no_fmp_event.json', import.meta); describe('Performance: bootup-time audit', () => { const auditOptions = Object.assign({}, BootupTime.defaultOptions, {thresholdInMs: 10}); diff --git a/lighthouse-core/test/audits/byte-efficiency/byte-efficiency-audit-test.js b/lighthouse-core/test/audits/byte-efficiency/byte-efficiency-audit-test.js index 96be7c73ed6b..add300cc1651 100644 --- a/lighthouse-core/test/audits/byte-efficiency/byte-efficiency-audit-test.js +++ b/lighthouse-core/test/audits/byte-efficiency/byte-efficiency-audit-test.js @@ -12,11 +12,13 @@ import CPUNode from '../../../lib/dependency-graph/cpu-node.js'; import Simulator from '../../../lib/dependency-graph/simulator/simulator.js'; import PageDependencyGraph from '../../../computed/page-dependency-graph.js'; import LoadSimulator from '../../../computed/load-simulator.js'; -import trace from '../../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; -import traceM78 from '../../fixtures/traces/lcp-m78.json'; -import devtoolsLogM78 from '../../fixtures/traces/lcp-m78.devtools.log.json'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; +import {readJson} from '../../../../root.js'; + +const trace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); +const traceM78 = readJson('../../fixtures/traces/lcp-m78.json', import.meta); +const devtoolsLogM78 = readJson('../../fixtures/traces/lcp-m78.devtools.log.json', import.meta); describe('Byte efficiency base audit', () => { let graph; diff --git a/lighthouse-core/test/audits/byte-efficiency/duplicated-javascript-test.js b/lighthouse-core/test/audits/byte-efficiency/duplicated-javascript-test.js index c7d13f9e863f..6d6d926cc926 100644 --- a/lighthouse-core/test/audits/byte-efficiency/duplicated-javascript-test.js +++ b/lighthouse-core/test/audits/byte-efficiency/duplicated-javascript-test.js @@ -4,15 +4,17 @@ * 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. */ +import {readJson} from '../../../../root.js'; import DuplicatedJavascript from '../../../audits/byte-efficiency/duplicated-javascript.js'; -import trace from '../../fixtures/traces/lcp-m78.json'; -import devtoolsLog from '../../fixtures/traces/lcp-m78.devtools.log.json'; import { loadSourceMapFixture, createScript, getURLArtifactFromDevtoolsLog, } from '../../test-utils.js'; +const trace = readJson('../../fixtures/traces/lcp-m78.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/lcp-m78.devtools.log.json', import.meta); + describe('DuplicatedJavascript computed artifact', () => { it('works (simple)', async () => { const context = {computedCache: new Map(), options: {ignoreThresholdInBytes: 200}}; diff --git a/lighthouse-core/test/audits/byte-efficiency/render-blocking-resources-test.js b/lighthouse-core/test/audits/byte-efficiency/render-blocking-resources-test.js index a338c9aae5cb..10ea14fe0f07 100644 --- a/lighthouse-core/test/audits/byte-efficiency/render-blocking-resources-test.js +++ b/lighthouse-core/test/audits/byte-efficiency/render-blocking-resources-test.js @@ -12,11 +12,13 @@ import NetworkNode from '../../../lib/dependency-graph/network-node.js'; import CPUNode from '../../../lib/dependency-graph/cpu-node.js'; import Simulator from '../../../lib/dependency-graph/simulator/simulator.js'; import NetworkRequest from '../../../lib/network-request.js'; -import trace from '../../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; -import ampTrace from '../../fixtures/traces/amp-m86.trace.json'; -import ampDevtoolsLog from '../../fixtures/traces/amp-m86.devtoolslog.json'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; +import {readJson} from '../../../../root.js'; + +const trace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); +const ampTrace = readJson('../../fixtures/traces/amp-m86.trace.json', import.meta); +const ampDevtoolsLog = readJson('../../fixtures/traces/amp-m86.devtoolslog.json', import.meta); const mobileSlow4G = constants.throttling.mobileSlow4G; diff --git a/lighthouse-core/test/audits/critical-request-chains-test.js b/lighthouse-core/test/audits/critical-request-chains-test.js index efc5ce46e9c0..e1521b76e233 100644 --- a/lighthouse-core/test/audits/critical-request-chains-test.js +++ b/lighthouse-core/test/audits/critical-request-chains-test.js @@ -6,11 +6,13 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../root.js'; import CriticalRequestChains from '../../audits/critical-request-chains.js'; -import redditDevtoolsLog from '../fixtures/artifacts/perflog/defaultPass.devtoolslog.json'; import createTestTrace from '../create-test-trace.js'; import networkRecordsToDevtoolsLog from '../network-records-to-devtools-log.js'; +const redditDevtoolsLog = readJson('../fixtures/artifacts/perflog/defaultPass.devtoolslog.json', import.meta); + const FAILING_CHAIN_RECORDS = [ { endTime: 5, diff --git a/lighthouse-core/test/audits/diagnostics-test.js b/lighthouse-core/test/audits/diagnostics-test.js index 00b3267a4831..5f05b4e576a8 100644 --- a/lighthouse-core/test/audits/diagnostics-test.js +++ b/lighthouse-core/test/audits/diagnostics-test.js @@ -4,9 +4,11 @@ * 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. */ +import {readJson} from '../../../root.js'; import Diagnostics from '../../audits/diagnostics.js'; -import acceptableTrace from '../fixtures/traces/progressive-app-m60.json'; -import acceptableDevToolsLog from '../fixtures/traces/progressive-app-m60.devtools.log.json'; + +const acceptableTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); +const acceptableDevToolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); describe('Diagnostics audit', () => { it('should work', async () => { diff --git a/lighthouse-core/test/audits/dobetterweb/uses-http2-test.js b/lighthouse-core/test/audits/dobetterweb/uses-http2-test.js index 98ca0e66424a..8d927fecb139 100644 --- a/lighthouse-core/test/audits/dobetterweb/uses-http2-test.js +++ b/lighthouse-core/test/audits/dobetterweb/uses-http2-test.js @@ -4,13 +4,15 @@ * 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. */ +import {readJson} from '../../../../root.js'; import UsesHTTP2Audit from '../../../audits/dobetterweb/uses-http2.js'; -import trace from '../../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; import NetworkRecords from '../../../computed/network-records.js'; import networkRecordsToDevtoolsLog from '../../network-records-to-devtools-log.js'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; +const trace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); + describe('Resources are fetched over http/2', () => { let artifacts = {}; let context = {}; diff --git a/lighthouse-core/test/audits/final-screenshot-test.js b/lighthouse-core/test/audits/final-screenshot-test.js index df1d8e1ef275..8e7905f48dec 100644 --- a/lighthouse-core/test/audits/final-screenshot-test.js +++ b/lighthouse-core/test/audits/final-screenshot-test.js @@ -4,8 +4,10 @@ * 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. */ +import {readJson} from '../../../root.js'; import FinalScreenshotAudit from '../../audits/final-screenshot.js'; -import pwaTrace from '../fixtures/traces/progressive-app-m60.json'; + +const pwaTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); const noScreenshotsTrace = {traceEvents: pwaTrace.traceEvents.filter(e => e.name !== 'Screenshot')}; diff --git a/lighthouse-core/test/audits/installable-manifest-test.js b/lighthouse-core/test/audits/installable-manifest-test.js index 6f4fd944059c..6a0fdd3dcd85 100644 --- a/lighthouse-core/test/audits/installable-manifest-test.js +++ b/lighthouse-core/test/audits/installable-manifest-test.js @@ -6,10 +6,12 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../root.js'; import InstallableManifestAudit from '../../audits/installable-manifest.js'; import manifestParser from '../../lib/manifest-parser.js'; -import manifest from '../fixtures/manifest.json'; -import manifestDirtyJpg from '../fixtures/manifest-dirty-jpg.json'; + +const manifest = readJson('../fixtures/manifest.json', import.meta); +const manifestDirtyJpg = readJson('../fixtures/manifest-dirty-jpg.json', import.meta); const manifestSrc = JSON.stringify(manifest); const manifestDirtyJpgSrc = JSON.stringify(manifestDirtyJpg); diff --git a/lighthouse-core/test/audits/main-thread-tasks-test.js b/lighthouse-core/test/audits/main-thread-tasks-test.js index 6e8a18c4d320..76627a753aa4 100644 --- a/lighthouse-core/test/audits/main-thread-tasks-test.js +++ b/lighthouse-core/test/audits/main-thread-tasks-test.js @@ -4,8 +4,10 @@ * 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. */ +import {readJson} from '../../../root.js'; import MainThreadTasks from '../../audits/main-thread-tasks.js'; -import acceptableTrace from '../fixtures/traces/progressive-app-m60.json'; + +const acceptableTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); describe('Main thread tasks audit', () => { it('should work', async () => { diff --git a/lighthouse-core/test/audits/mainthread-work-breakdown-test.js b/lighthouse-core/test/audits/mainthread-work-breakdown-test.js index a700f674ce37..2b6a499ebd1a 100644 --- a/lighthouse-core/test/audits/mainthread-work-breakdown-test.js +++ b/lighthouse-core/test/audits/mainthread-work-breakdown-test.js @@ -6,11 +6,13 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../root.js'; import PageExecutionTimings from '../../audits/mainthread-work-breakdown.js'; -import acceptableTrace from '../fixtures/traces/progressive-app-m60.json'; -import siteWithRedirectTrace from '../fixtures/traces/site-with-redirect.json'; -import loadTrace from '../fixtures/traces/load.json'; -import errorTrace from '../fixtures/traces/no_fmp_event.json'; + +const acceptableTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); +const siteWithRedirectTrace = readJson('../fixtures/traces/site-with-redirect.json', import.meta); +const loadTrace = readJson('../fixtures/traces/load.json', import.meta); +const errorTrace = readJson('../fixtures/traces/no_fmp_event.json', import.meta); const options = PageExecutionTimings.defaultOptions; diff --git a/lighthouse-core/test/audits/maskable-icon-test.js b/lighthouse-core/test/audits/maskable-icon-test.js index 6b0391d60cfc..e17bb64d468e 100644 --- a/lighthouse-core/test/audits/maskable-icon-test.js +++ b/lighthouse-core/test/audits/maskable-icon-test.js @@ -4,10 +4,12 @@ * 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. */ +import {readJson} from '../../../root.js'; import MaskableIconAudit from '../../audits/maskable-icon.js'; import manifestParser from '../../lib/manifest-parser.js'; -import manifest from '../fixtures/manifest.json'; -import manifestWithoutMaskable from '../fixtures/manifest-no-maskable-icon.json'; + +const manifest = readJson('../fixtures/manifest.json', import.meta); +const manifestWithoutMaskable = readJson('../fixtures/manifest-no-maskable-icon.json', import.meta); const manifestSrc = JSON.stringify(manifest); const manifestWithoutMaskableSrc = JSON.stringify(manifestWithoutMaskable); diff --git a/lighthouse-core/test/audits/metrics-test.js b/lighthouse-core/test/audits/metrics-test.js index ed978b2e57b6..82ee756505db 100644 --- a/lighthouse-core/test/audits/metrics-test.js +++ b/lighthouse-core/test/audits/metrics-test.js @@ -6,20 +6,22 @@ import {jest} from '@jest/globals'; +import {readJson} from '../../../root.js'; import MetricsAudit from '../../audits/metrics.js'; import TTIComputed from '../../computed/metrics/interactive.js'; -import pwaTrace from '../fixtures/traces/progressive-app-m60.json'; -import pwaDevtoolsLog from '../fixtures/traces/progressive-app-m60.devtools.log.json'; -import lcpTrace from '../fixtures/traces/lcp-m78.json'; -import lcpDevtoolsLog from '../fixtures/traces/lcp-m78.devtools.log.json'; -import lcpAllFramesTrace from '../fixtures/traces/frame-metrics-m89.json'; -import lcpAllFramesDevtoolsLog from '../fixtures/traces/frame-metrics-m89.devtools.log.json'; // eslint-disable-line max-len -import clsAllFramesTrace from '../fixtures/traces/frame-metrics-m90.json'; -import clsAllFramesDevtoolsLog from '../fixtures/traces/frame-metrics-m90.devtools.log.json'; // eslint-disable-line max-len -import jumpyClsTrace from '../fixtures/traces/jumpy-cls-m90.json'; -import jumpyClsDevtoolsLog from '../fixtures/traces/jumpy-cls-m90.devtoolslog.json'; import {getURLArtifactFromDevtoolsLog} from '../test-utils.js'; +const pwaTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); +const pwaDevtoolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); +const lcpTrace = readJson('../fixtures/traces/lcp-m78.json', import.meta); +const lcpDevtoolsLog = readJson('../fixtures/traces/lcp-m78.devtools.log.json', import.meta); +const lcpAllFramesTrace = readJson('../fixtures/traces/frame-metrics-m89.json', import.meta); +const lcpAllFramesDevtoolsLog = readJson('../fixtures/traces/frame-metrics-m89.devtools.log.json', import.meta); +const clsAllFramesTrace = readJson('../fixtures/traces/frame-metrics-m90.json', import.meta); +const clsAllFramesDevtoolsLog = readJson('../fixtures/traces/frame-metrics-m90.devtools.log.json', import.meta); +const jumpyClsTrace = readJson('../fixtures/traces/jumpy-cls-m90.json', import.meta); +const jumpyClsDevtoolsLog = readJson('../fixtures/traces/jumpy-cls-m90.devtoolslog.json', import.meta); + describe('Performance: metrics', () => { it('evaluates valid input correctly', async () => { const URL = getURLArtifactFromDevtoolsLog(pwaDevtoolsLog); diff --git a/lighthouse-core/test/audits/metrics/cumulative-layout-shift-test.js b/lighthouse-core/test/audits/metrics/cumulative-layout-shift-test.js index dc7f4a884301..eaa4205f8616 100644 --- a/lighthouse-core/test/audits/metrics/cumulative-layout-shift-test.js +++ b/lighthouse-core/test/audits/metrics/cumulative-layout-shift-test.js @@ -4,8 +4,10 @@ * 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. */ +import {readJson} from '../../../../root.js'; import CumulativeLayoutShift from '../../../audits/metrics/cumulative-layout-shift.js'; -import jumpyClsTrace from '../../fixtures/traces/jumpy-cls-m90.json'; + +const jumpyClsTrace = readJson('../../fixtures/traces/jumpy-cls-m90.json', import.meta); describe('Cumulative Layout Shift', () => { it('evaluates CLS correctly', async () => { diff --git a/lighthouse-core/test/audits/metrics/experimental-interaction-to-next-paint-test.js b/lighthouse-core/test/audits/metrics/experimental-interaction-to-next-paint-test.js index 6774e13a4050..896b2409da91 100644 --- a/lighthouse-core/test/audits/metrics/experimental-interaction-to-next-paint-test.js +++ b/lighthouse-core/test/audits/metrics/experimental-interaction-to-next-paint-test.js @@ -4,10 +4,12 @@ * 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. */ +import {readJson} from '../../../../root.js'; import ExperimentalInteractionToNextPaint from '../../../audits/metrics/experimental-interaction-to-next-paint.js'; -import interactionTrace from '../../fixtures/traces/timespan-responsiveness-m103.trace.json'; -import noInteractionTrace from '../../fixtures/traces/jumpy-cls-m90.json'; + +const interactionTrace = readJson('../../fixtures/traces/timespan-responsiveness-m103.trace.json', import.meta); +const noInteractionTrace = readJson('../../fixtures/traces/jumpy-cls-m90.json', import.meta); describe('Interaction to Next Paint', () => { function getTestData() { diff --git a/lighthouse-core/test/audits/metrics/first-contentful-paint-3g-test.js b/lighthouse-core/test/audits/metrics/first-contentful-paint-3g-test.js index c741a802fcb1..be3c94ea5cba 100644 --- a/lighthouse-core/test/audits/metrics/first-contentful-paint-3g-test.js +++ b/lighthouse-core/test/audits/metrics/first-contentful-paint-3g-test.js @@ -4,11 +4,13 @@ * 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. */ +import {readJson} from '../../../../root.js'; import FCP3G from '../../../audits/metrics/first-contentful-paint-3g.js'; -import pwaTrace from '../../fixtures/traces/progressive-app-m60.json'; -import pwaDevtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; +const pwaTrace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const pwaDevtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); + const options = FCP3G.defaultOptions; describe('Performance: first-contentful-paint-3g audit', () => { diff --git a/lighthouse-core/test/audits/metrics/first-contentful-paint-test.js b/lighthouse-core/test/audits/metrics/first-contentful-paint-test.js index ee52cc307398..4986f8aeeab7 100644 --- a/lighthouse-core/test/audits/metrics/first-contentful-paint-test.js +++ b/lighthouse-core/test/audits/metrics/first-contentful-paint-test.js @@ -6,12 +6,14 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../../root.js'; import FcpAudit from '../../../audits/metrics/first-contentful-paint.js'; import constants from '../../../config/constants.js'; -import pwaTrace from '../../fixtures/traces/progressive-app-m60.json'; -import pwaDevtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; -import frameTrace from '../../fixtures/traces/frame-metrics-m90.json'; -import frameDevtoolsLog from '../../fixtures/traces/frame-metrics-m90.devtools.log.json'; + +const pwaTrace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const pwaDevtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); +const frameTrace = readJson('../../fixtures/traces/frame-metrics-m90.json', import.meta); +const frameDevtoolsLog = readJson('../../fixtures/traces/frame-metrics-m90.devtools.log.json', import.meta); const options = FcpAudit.defaultOptions; diff --git a/lighthouse-core/test/audits/metrics/first-meaningful-paint-test.js b/lighthouse-core/test/audits/metrics/first-meaningful-paint-test.js index e353e6cba689..e870a8ee64c9 100644 --- a/lighthouse-core/test/audits/metrics/first-meaningful-paint-test.js +++ b/lighthouse-core/test/audits/metrics/first-meaningful-paint-test.js @@ -9,9 +9,11 @@ import {strict as assert} from 'assert'; import FMPAudit from '../../../audits/metrics/first-meaningful-paint.js'; import Audit from '../../../audits/audit.js'; import constants from '../../../config/constants.js'; -import trace from '../../fixtures/traces/progressive-app-m60.json'; -import devtoolsLogs from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; +import {readJson} from '../../../../root.js'; + +const trace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLogs = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); /** * @param {{ diff --git a/lighthouse-core/test/audits/metrics/interactive-test.js b/lighthouse-core/test/audits/metrics/interactive-test.js index 68d6f7326343..7843ff0e890a 100644 --- a/lighthouse-core/test/audits/metrics/interactive-test.js +++ b/lighthouse-core/test/audits/metrics/interactive-test.js @@ -6,12 +6,14 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../../root.js'; import Interactive from '../../../audits/metrics/interactive.js'; import constants from '../../../config/constants.js'; -import acceptableTrace from '../../fixtures/traces/progressive-app-m60.json'; -import acceptableDevToolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; -import redirectTrace from '../../fixtures/traces/site-with-redirect.json'; -import redirectDevToolsLog from '../../fixtures/traces/site-with-redirect.devtools.log.json'; + +const acceptableTrace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const acceptableDevToolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); +const redirectTrace = readJson('../../fixtures/traces/site-with-redirect.json', import.meta); +const redirectDevToolsLog = readJson('../../fixtures/traces/site-with-redirect.devtools.log.json', import.meta); const options = Interactive.defaultOptions; diff --git a/lighthouse-core/test/audits/metrics/largest-contentful-paint-test.js b/lighthouse-core/test/audits/metrics/largest-contentful-paint-test.js index 357707373556..32fa6a36e7a3 100644 --- a/lighthouse-core/test/audits/metrics/largest-contentful-paint-test.js +++ b/lighthouse-core/test/audits/metrics/largest-contentful-paint-test.js @@ -4,12 +4,14 @@ * 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. */ +import {readJson} from '../../../../root.js'; import LCPAudit from '../../../audits/metrics/largest-contentful-paint.js'; import constants from '../../../config/constants.js'; -import trace from '../../fixtures/traces/lcp-m78.json'; -import devtoolsLog from '../../fixtures/traces/lcp-m78.devtools.log.json'; -import preLcpTrace from '../../fixtures/traces/progressive-app-m60.json'; -import preLcpDevtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; + +const trace = readJson('../../fixtures/traces/lcp-m78.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/lcp-m78.devtools.log.json', import.meta); +const preLcpTrace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const preLcpDevtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); const defaultOptions = LCPAudit.defaultOptions; diff --git a/lighthouse-core/test/audits/metrics/speed-index-test.js b/lighthouse-core/test/audits/metrics/speed-index-test.js index 3a615dd67bb9..b2820631f898 100644 --- a/lighthouse-core/test/audits/metrics/speed-index-test.js +++ b/lighthouse-core/test/audits/metrics/speed-index-test.js @@ -6,10 +6,12 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../../root.js'; import Audit from '../../../audits/metrics/speed-index.js'; import constants from '../../../config/constants.js'; -import pwaTrace from '../../fixtures/traces/progressive-app-m60.json'; -import pwaDevtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; + +const pwaTrace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const pwaDevtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); const options = Audit.defaultOptions; diff --git a/lighthouse-core/test/audits/metrics/total-blocking-time-test.js b/lighthouse-core/test/audits/metrics/total-blocking-time-test.js index 882834b9a52d..82493e9a8d67 100644 --- a/lighthouse-core/test/audits/metrics/total-blocking-time-test.js +++ b/lighthouse-core/test/audits/metrics/total-blocking-time-test.js @@ -4,14 +4,16 @@ * 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. */ +import {readJson} from '../../../../root.js'; import TBTAudit from '../../../audits/metrics/total-blocking-time.js'; import constants from '../../../config/constants.js'; -import trace from '../../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; -import lcpTrace from '../../fixtures/traces/lcp-m78.json'; -import lcpDevtoolsLog from '../../fixtures/traces/lcp-m78.devtools.log.json'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; +const trace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); +const lcpTrace = readJson('../../fixtures/traces/lcp-m78.json', import.meta); +const lcpDevtoolsLog = readJson('../../fixtures/traces/lcp-m78.devtools.log.json', import.meta); + const defaultOptions = TBTAudit.defaultOptions; function generateArtifacts({gatherMode = 'navigation', trace, devtoolsLog}) { diff --git a/lighthouse-core/test/audits/network-requests-test.js b/lighthouse-core/test/audits/network-requests-test.js index e528615f04ee..0ff6997ea2df 100644 --- a/lighthouse-core/test/audits/network-requests-test.js +++ b/lighthouse-core/test/audits/network-requests-test.js @@ -4,9 +4,12 @@ * 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. */ +import {readJson} from '../../../root.js'; import NetworkRequests from '../../audits/network-requests.js'; import networkRecordsToDevtoolsLog from '../network-records-to-devtools-log.js'; -import cutoffLoadDevtoolsLog from '../fixtures/traces/cutoff-load-m83.devtoolslog.json'; + +const cutoffLoadDevtoolsLog = readJson('../fixtures/traces/cutoff-load-m83.devtoolslog.json', import.meta); + describe('Network requests audit', () => { it('should report finished and unfinished network requests', async () => { const artifacts = { diff --git a/lighthouse-core/test/audits/network-rtt-test.js b/lighthouse-core/test/audits/network-rtt-test.js index bdc2ce30057d..78755008b5a5 100644 --- a/lighthouse-core/test/audits/network-rtt-test.js +++ b/lighthouse-core/test/audits/network-rtt-test.js @@ -4,8 +4,10 @@ * 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. */ +import {readJson} from '../../../root.js'; import NetworkRTT from '../../audits/network-rtt.js'; -import acceptableDevToolsLog from '../fixtures/traces/progressive-app-m60.devtools.log.json'; + +const acceptableDevToolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); describe('Network RTT audit', () => { it('should work', async () => { diff --git a/lighthouse-core/test/audits/network-server-latency-test.js b/lighthouse-core/test/audits/network-server-latency-test.js index c924b3672cb2..ab00d229b904 100644 --- a/lighthouse-core/test/audits/network-server-latency-test.js +++ b/lighthouse-core/test/audits/network-server-latency-test.js @@ -4,8 +4,10 @@ * 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. */ +import {readJson} from '../../../root.js'; import ServerLatency from '../../audits/network-server-latency.js'; -import acceptableDevToolsLog from '../fixtures/traces/progressive-app-m60.devtools.log.json'; + +const acceptableDevToolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); describe('Network Server Latency audit', () => { it('should work', async () => { diff --git a/lighthouse-core/test/audits/predictive-perf-test.js b/lighthouse-core/test/audits/predictive-perf-test.js index 919a6baba9e5..95ce69cd912f 100644 --- a/lighthouse-core/test/audits/predictive-perf-test.js +++ b/lighthouse-core/test/audits/predictive-perf-test.js @@ -4,10 +4,13 @@ * 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. */ +import {readJson} from '../../../root.js'; import PredictivePerf from '../../audits/predictive-perf.js'; -import acceptableTrace from '../fixtures/traces/lcp-m78.json'; -import acceptableDevToolsLog from '../fixtures/traces/lcp-m78.devtools.log.json'; import {getURLArtifactFromDevtoolsLog} from '../test-utils.js'; + +const acceptableTrace = readJson('../fixtures/traces/lcp-m78.json', import.meta); +const acceptableDevToolsLog = readJson('../fixtures/traces/lcp-m78.devtools.log.json', import.meta); + describe('Performance: predictive performance audit', () => { it('should compute the predicted values', async () => { const artifacts = { diff --git a/lighthouse-core/test/audits/screenshot-thumbnails-test.js b/lighthouse-core/test/audits/screenshot-thumbnails-test.js index dda1167967ca..30b7751941fb 100644 --- a/lighthouse-core/test/audits/screenshot-thumbnails-test.js +++ b/lighthouse-core/test/audits/screenshot-thumbnails-test.js @@ -9,9 +9,10 @@ import path from 'path'; import {strict as assert} from 'assert'; import ScreenshotThumbnailsAudit from '../../audits/screenshot-thumbnails.js'; -import pwaTrace from '../fixtures/traces/progressive-app-m60.json'; -import pwaDevtoolsLog from '../fixtures/traces/progressive-app-m60.devtools.log.json'; -import {LH_ROOT} from '../../../root.js'; +import {LH_ROOT, readJson} from '../../../root.js'; + +const pwaTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); +const pwaDevtoolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); const noScreenshotsTrace = {traceEvents: pwaTrace.traceEvents.filter(e => e.name !== 'Screenshot')}; diff --git a/lighthouse-core/test/audits/splash-screen-test.js b/lighthouse-core/test/audits/splash-screen-test.js index 63d88f2685b9..4bcf221e754b 100644 --- a/lighthouse-core/test/audits/splash-screen-test.js +++ b/lighthouse-core/test/audits/splash-screen-test.js @@ -6,10 +6,12 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../root.js'; import SplashScreenAudit from '../../audits/splash-screen.js'; import manifestParser from '../../lib/manifest-parser.js'; -import manifest from '../fixtures/manifest.json'; -import manifestDirtyJpg from '../fixtures/manifest-dirty-jpg.json'; + +const manifest = readJson('../fixtures/manifest.json', import.meta); +const manifestDirtyJpg = readJson('../fixtures/manifest-dirty-jpg.json', import.meta); const manifestSrc = JSON.stringify(manifest); const manifestDirtyJpgSrc = JSON.stringify(manifestDirtyJpg); diff --git a/lighthouse-core/test/audits/themed-omnibox-test.js b/lighthouse-core/test/audits/themed-omnibox-test.js index b30f0d36f954..3c205b83efb1 100644 --- a/lighthouse-core/test/audits/themed-omnibox-test.js +++ b/lighthouse-core/test/audits/themed-omnibox-test.js @@ -6,9 +6,11 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../root.js'; import ThemedOmniboxAudit from '../../audits/themed-omnibox.js'; import manifestParser from '../../lib/manifest-parser.js'; -import manifest from '../fixtures/manifest.json'; + +const manifest = readJson('../fixtures/manifest.json', import.meta); const manifestSrc = JSON.stringify(manifest); const EXAMPLE_MANIFEST_URL = 'https://example.com/manifest.json'; diff --git a/lighthouse-core/test/audits/third-party-facades-test.js b/lighthouse-core/test/audits/third-party-facades-test.js index b1e09a48a4d5..41603dcd9687 100644 --- a/lighthouse-core/test/audits/third-party-facades-test.js +++ b/lighthouse-core/test/audits/third-party-facades-test.js @@ -7,12 +7,14 @@ import ThirdPartyFacades from '../../audits/third-party-facades.js'; import networkRecordsToDevtoolsLog from '../network-records-to-devtools-log.js'; import createTestTrace from '../create-test-trace.js'; -import pwaTrace from '../fixtures/traces/progressive-app-m60.json'; -import pwaDevtoolsLog from '../fixtures/traces/progressive-app-m60.devtools.log.json'; -import videoEmbedsTrace from '../fixtures/traces/video-embeds-m84.json'; -import videoEmbedsDevtolsLog from '../fixtures/traces/video-embeds-m84.devtools.log.json'; -import noThirdPartyTrace from '../fixtures/traces/no-tracingstarted-m74.json'; import {getURLArtifactFromDevtoolsLog} from '../test-utils.js'; +import {readJson} from '../../../root.js'; + +const pwaTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); +const pwaDevtoolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); +const videoEmbedsTrace = readJson('../fixtures/traces/video-embeds-m84.json', import.meta); +const videoEmbedsDevtolsLog = readJson('../fixtures/traces/video-embeds-m84.devtools.log.json', import.meta); +const noThirdPartyTrace = readJson('../fixtures/traces/no-tracingstarted-m74.json', import.meta); function intercomProductUrl(id) { return `https://widget.intercom.io/widget/${id}`; diff --git a/lighthouse-core/test/audits/third-party-summary-test.js b/lighthouse-core/test/audits/third-party-summary-test.js index c6716ced0994..283014dce7a6 100644 --- a/lighthouse-core/test/audits/third-party-summary-test.js +++ b/lighthouse-core/test/audits/third-party-summary-test.js @@ -4,11 +4,14 @@ * 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. */ +import {readJson} from '../../../root.js'; import ThirdPartySummary from '../../audits/third-party-summary.js'; import networkRecordsToDevtoolsLog from '../network-records-to-devtools-log.js'; -import pwaTrace from '../fixtures/traces/progressive-app-m60.json'; -import pwaDevtoolsLog from '../fixtures/traces/progressive-app-m60.devtools.log.json'; -import noThirdPartyTrace from '../fixtures/traces/no-tracingstarted-m74.json'; + +const pwaTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); +const pwaDevtoolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); +const noThirdPartyTrace = readJson('../fixtures/traces/no-tracingstarted-m74.json', import.meta); + describe('Third party summary', () => { it('surface the discovered third parties', async () => { const artifacts = { diff --git a/lighthouse-core/test/audits/timing-budget-test.js b/lighthouse-core/test/audits/timing-budget-test.js index ba2b8b7cfbd7..3db7bc93bf7a 100644 --- a/lighthouse-core/test/audits/timing-budget-test.js +++ b/lighthouse-core/test/audits/timing-budget-test.js @@ -4,13 +4,15 @@ * 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. */ +import {readJson} from '../../../root.js'; import TimingBudgetAudit from '../../audits/timing-budget.js'; -import trace from '../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../fixtures/traces/progressive-app-m60.devtools.log.json'; -import lcpTrace from '../fixtures/traces/lcp-m78.json'; -import lcpDevtoolsLog from '../fixtures/traces/lcp-m78.devtools.log.json'; import {getURLArtifactFromDevtoolsLog} from '../test-utils.js'; +const trace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); +const lcpTrace = readJson('../fixtures/traces/lcp-m78.json', import.meta); +const lcpDevtoolsLog = readJson('../fixtures/traces/lcp-m78.devtools.log.json', import.meta); + describe('Performance: Timing budget audit', () => { let artifacts; let context; diff --git a/lighthouse-core/test/audits/user-timing-test.js b/lighthouse-core/test/audits/user-timing-test.js index 261e9c1c7943..c2d6fcd597f9 100644 --- a/lighthouse-core/test/audits/user-timing-test.js +++ b/lighthouse-core/test/audits/user-timing-test.js @@ -6,8 +6,10 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../root.js'; import UserTimingsAudit from '../../audits/user-timings.js'; -import traceEvents from '../fixtures/traces/trace-user-timings.json'; + +const traceEvents = readJson('../fixtures/traces/trace-user-timings.json', import.meta); function generateArtifactsWithTrace(trace) { return { diff --git a/lighthouse-core/test/audits/uses-rel-preload-test.js b/lighthouse-core/test/audits/uses-rel-preload-test.js index 060c7046e0ef..57cf34fc43db 100644 --- a/lighthouse-core/test/audits/uses-rel-preload-test.js +++ b/lighthouse-core/test/audits/uses-rel-preload-test.js @@ -7,11 +7,13 @@ import {strict as assert} from 'assert'; import UsesRelPreload from '../../audits/uses-rel-preload.js'; -import pwaTrace from '../fixtures/traces/progressive-app-m60.json'; -import pwaDevtoolsLog from '../fixtures/traces/progressive-app-m60.devtools.log.json'; import networkRecordsToDevtoolsLog from '../network-records-to-devtools-log.js'; import createTestTrace from '../create-test-trace.js'; import {getURLArtifactFromDevtoolsLog} from '../test-utils.js'; +import {readJson} from '../../../root.js'; + +const pwaTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); +const pwaDevtoolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); const defaultMainResourceUrl = 'http://www.example.com/'; const defaultMainResource = { diff --git a/lighthouse-core/test/audits/work-during-interaction-test.js b/lighthouse-core/test/audits/work-during-interaction-test.js index d2efa35a8e9d..d84d91725290 100644 --- a/lighthouse-core/test/audits/work-during-interaction-test.js +++ b/lighthouse-core/test/audits/work-during-interaction-test.js @@ -6,9 +6,11 @@ /* eslint-disable no-irregular-whitespace */ +import {readJson} from '../../../root.js'; import WorkDuringInteraction from '../../audits/work-during-interaction.js'; -import interactionTrace from '../fixtures/traces/timespan-responsiveness-m103.trace.json'; -import noInteractionTrace from '../fixtures/traces/jumpy-cls-m90.json'; + +const interactionTrace = readJson('../fixtures/traces/timespan-responsiveness-m103.trace.json', import.meta); +const noInteractionTrace = readJson('../fixtures/traces/jumpy-cls-m90.json', import.meta); describe('Interaction to Next Paint', () => { function getTestData() { diff --git a/lighthouse-core/test/computed/critical-request-chains-test.js b/lighthouse-core/test/computed/critical-request-chains-test.js index 1108496e5a12..7c8234614f93 100644 --- a/lighthouse-core/test/computed/critical-request-chains-test.js +++ b/lighthouse-core/test/computed/critical-request-chains-test.js @@ -6,12 +6,14 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../root.js'; import CriticalRequestChains from '../../computed/critical-request-chains.js'; import NetworkRequest from '../../lib/network-request.js'; import createTestTrace from '../create-test-trace.js'; import networkRecordsToDevtoolsLog from '../network-records-to-devtools-log.js'; import {getURLArtifactFromDevtoolsLog} from '../test-utils.js'; -import wikipediaDevtoolsLog from '../fixtures/wikipedia-redirect.devtoolslog.json'; + +const wikipediaDevtoolsLog = readJson('../fixtures/wikipedia-redirect.devtoolslog.json', import.meta); const HIGH = 'High'; const VERY_HIGH = 'VeryHigh'; diff --git a/lighthouse-core/test/computed/load-simulator-test.js b/lighthouse-core/test/computed/load-simulator-test.js index d079707fc7cc..89d1d66e97fa 100644 --- a/lighthouse-core/test/computed/load-simulator-test.js +++ b/lighthouse-core/test/computed/load-simulator-test.js @@ -6,10 +6,12 @@ import {strict as assert} from 'assert'; -import devtoolsLog from '../fixtures/traces/progressive-app-m60.devtools.log.json'; +import {readJson} from '../../../root.js'; import LoadSimulator from '../../computed/load-simulator.js'; import NetworkNode from '../../lib/dependency-graph/network-node.js'; +const devtoolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); + function createNetworkNode() { return new NetworkNode({ requestId: '1', diff --git a/lighthouse-core/test/computed/main-resource-test.js b/lighthouse-core/test/computed/main-resource-test.js index 5c9f8821315d..9e85b083f000 100644 --- a/lighthouse-core/test/computed/main-resource-test.js +++ b/lighthouse-core/test/computed/main-resource-test.js @@ -6,9 +6,11 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../root.js'; import MainResource from '../../computed/main-resource.js'; import networkRecordsToDevtoolsLog from '../network-records-to-devtools-log.js'; -import wikipediaDevtoolsLog from '../fixtures/wikipedia-redirect.devtoolslog.json'; + +const wikipediaDevtoolsLog = readJson('../fixtures/wikipedia-redirect.devtoolslog.json', import.meta); describe('MainResource computed artifact', () => { it('returns an artifact', () => { diff --git a/lighthouse-core/test/computed/main-thread-tasks-test.js b/lighthouse-core/test/computed/main-thread-tasks-test.js index a6cf73390aff..efabb3c84428 100644 --- a/lighthouse-core/test/computed/main-thread-tasks-test.js +++ b/lighthouse-core/test/computed/main-thread-tasks-test.js @@ -4,8 +4,10 @@ * 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. */ +import {readJson} from '../../../root.js'; import MainThreadTasks from '../../computed/main-thread-tasks.js'; -import pwaTrace from '../fixtures/traces/progressive-app-m60.json'; + +const pwaTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); describe('MainThreadTasksComputed', () => { it('computes the artifact', async () => { diff --git a/lighthouse-core/test/computed/manifest-values-test.js b/lighthouse-core/test/computed/manifest-values-test.js index 4c50756f9706..445c945d922a 100644 --- a/lighthouse-core/test/computed/manifest-values-test.js +++ b/lighthouse-core/test/computed/manifest-values-test.js @@ -6,9 +6,11 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../root.js'; import ManifestValues from '../../computed/manifest-values.js'; import manifestParser from '../../lib/manifest-parser.js'; -import manifest from '../fixtures/manifest.json'; + +const manifest = readJson('../fixtures/manifest.json', import.meta); const manifestSrc = JSON.stringify(manifest); diff --git a/lighthouse-core/test/computed/metrics/cumulative-layout-shift-test.js b/lighthouse-core/test/computed/metrics/cumulative-layout-shift-test.js index 9190359cd315..37db049d3847 100644 --- a/lighthouse-core/test/computed/metrics/cumulative-layout-shift-test.js +++ b/lighthouse-core/test/computed/metrics/cumulative-layout-shift-test.js @@ -4,12 +4,14 @@ * 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. */ +import {readJson} from '../../../../root.js'; import CumulativeLayoutShift from '../../../computed/metrics/cumulative-layout-shift.js'; import createTestTrace from '../../create-test-trace.js'; -import jumpyClsTrace from '../../fixtures/traces/jumpy-cls-m90.json'; -import oldMetricsTrace from '../../fixtures/traces/frame-metrics-m89.json'; -import allFramesMetricsTrace from '../../fixtures/traces/frame-metrics-m90.json'; -import preClsTrace from '../../fixtures/traces/progressive-app-m60.json'; + +const jumpyClsTrace = readJson('../../fixtures/traces/jumpy-cls-m90.json', import.meta); +const oldMetricsTrace = readJson('../../fixtures/traces/frame-metrics-m89.json', import.meta); +const allFramesMetricsTrace = readJson('../../fixtures/traces/frame-metrics-m90.json', import.meta); +const preClsTrace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); const childFrameId = 'CAF4634127666E186C9C8B35627DBF0B'; diff --git a/lighthouse-core/test/computed/metrics/first-contentful-paint-all-frames-test.js b/lighthouse-core/test/computed/metrics/first-contentful-paint-all-frames-test.js index e8726dc2faef..267fa1e9eeaf 100644 --- a/lighthouse-core/test/computed/metrics/first-contentful-paint-all-frames-test.js +++ b/lighthouse-core/test/computed/metrics/first-contentful-paint-all-frames-test.js @@ -4,10 +4,12 @@ * 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. */ +import {readJson} from '../../../../root.js'; import FirstContentfulPaintAllFrames from '../../../computed/metrics/first-contentful-paint-all-frames.js'; // eslint-disable-line max-len import FirstContentfulPaint from '../../../computed/metrics/first-contentful-paint.js'; // eslint-disable-line max-len -import trace from '../../fixtures/traces/frame-metrics-m89.json'; -import devtoolsLog from '../../fixtures/traces/frame-metrics-m89.devtools.log.json'; + +const trace = readJson('../../fixtures/traces/frame-metrics-m89.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/frame-metrics-m89.devtools.log.json', import.meta); describe('Metrics: FCP all frames', () => { const gatherContext = {gatherMode: 'navigation'}; diff --git a/lighthouse-core/test/computed/metrics/first-contentful-paint-test.js b/lighthouse-core/test/computed/metrics/first-contentful-paint-test.js index 0281410988ce..04ad4355a80a 100644 --- a/lighthouse-core/test/computed/metrics/first-contentful-paint-test.js +++ b/lighthouse-core/test/computed/metrics/first-contentful-paint-test.js @@ -6,11 +6,13 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../../root.js'; import FirstContentfulPaint from '../../../computed/metrics/first-contentful-paint.js'; // eslint-disable-line max-len -import trace from '../../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; +const trace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); + const URL = getURLArtifactFromDevtoolsLog(devtoolsLog); describe('Metrics: FCP', () => { diff --git a/lighthouse-core/test/computed/metrics/first-meaningful-paint-test.js b/lighthouse-core/test/computed/metrics/first-meaningful-paint-test.js index d09b9e00aee2..60f95abda258 100644 --- a/lighthouse-core/test/computed/metrics/first-meaningful-paint-test.js +++ b/lighthouse-core/test/computed/metrics/first-meaningful-paint-test.js @@ -6,14 +6,16 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../../root.js'; import FirstMeaningfulPaint from '../../../computed/metrics/first-meaningful-paint.js'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; -import pwaTrace from '../../fixtures/traces/progressive-app-m60.json'; -import pwaDevtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; -import badNavStartTrace from '../../fixtures/traces/bad-nav-start-ts.json'; -import lateTracingStartedTrace from '../../fixtures/traces/tracingstarted-after-navstart.json'; -import preactTrace from '../../fixtures/traces/preactjs.com_ts_of_undefined.json'; -import noFMPtrace from '../../fixtures/traces/no_fmp_event.json'; + +const pwaTrace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const pwaDevtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); +const badNavStartTrace = readJson('../../fixtures/traces/bad-nav-start-ts.json', import.meta); +const lateTracingStartedTrace = readJson('../../fixtures/traces/tracingstarted-after-navstart.json', import.meta); +const preactTrace = readJson('../../fixtures/traces/preactjs.com_ts_of_undefined.json', import.meta); +const noFMPtrace = readJson('../../fixtures/traces/no_fmp_event.json', import.meta); describe('Metrics: FMP', () => { const gatherContext = {gatherMode: 'navigation'}; diff --git a/lighthouse-core/test/computed/metrics/interactive-test.js b/lighthouse-core/test/computed/metrics/interactive-test.js index e4c2015ea3c4..89c1fbff26af 100644 --- a/lighthouse-core/test/computed/metrics/interactive-test.js +++ b/lighthouse-core/test/computed/metrics/interactive-test.js @@ -6,11 +6,13 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../../root.js'; import Interactive from '../../../computed/metrics/interactive.js'; -import trace from '../../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; +const trace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); + const URL = getURLArtifactFromDevtoolsLog(devtoolsLog); function generateNetworkRecords(records, timeOrigin) { diff --git a/lighthouse-core/test/computed/metrics/lantern-first-contentful-paint-test.js b/lighthouse-core/test/computed/metrics/lantern-first-contentful-paint-test.js index bd0ac0943306..5719aa98679b 100644 --- a/lighthouse-core/test/computed/metrics/lantern-first-contentful-paint-test.js +++ b/lighthouse-core/test/computed/metrics/lantern-first-contentful-paint-test.js @@ -7,11 +7,14 @@ import {strict as assert} from 'assert'; import LanternFirstContentfulPaint from '../../../computed/metrics/lantern-first-contentful-paint.js'; // eslint-disable-line max-len -import trace from '../../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; import networkRecordsToDevtoolsLog from '../../network-records-to-devtools-log.js'; import createTestTrace from '../../create-test-trace.js'; +import {readJson} from '../../../../root.js'; + +const trace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); + describe('Metrics: Lantern FCP', () => { const gatherContext = {gatherMode: 'navigation'}; diff --git a/lighthouse-core/test/computed/metrics/lantern-first-meaningful-paint-test.js b/lighthouse-core/test/computed/metrics/lantern-first-meaningful-paint-test.js index 6a7e0ab8d551..90c385355a3d 100644 --- a/lighthouse-core/test/computed/metrics/lantern-first-meaningful-paint-test.js +++ b/lighthouse-core/test/computed/metrics/lantern-first-meaningful-paint-test.js @@ -6,12 +6,14 @@ import {strict as assert} from 'assert'; -import trace from '../../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; +import {readJson} from '../../../../root.js'; import LanternFirstMeaningfulPaint from '../../../computed/metrics/lantern-first-meaningful-paint.js'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; +const trace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); + const URL = getURLArtifactFromDevtoolsLog(devtoolsLog); describe('Metrics: Lantern FMP', () => { it('should compute predicted value', async () => { diff --git a/lighthouse-core/test/computed/metrics/lantern-interactive-test.js b/lighthouse-core/test/computed/metrics/lantern-interactive-test.js index c0dd153263d1..31f36652c031 100644 --- a/lighthouse-core/test/computed/metrics/lantern-interactive-test.js +++ b/lighthouse-core/test/computed/metrics/lantern-interactive-test.js @@ -6,13 +6,15 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../../root.js'; import LanternInteractive from '../../../computed/metrics/lantern-interactive.js'; -import trace from '../../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; -import iframeTrace from '../../fixtures/traces/iframe-m79.trace.json'; -import iframeDevtoolsLog from '../../fixtures/traces/iframe-m79.devtoolslog.json'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; +const trace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); +const iframeTrace = readJson('../../fixtures/traces/iframe-m79.trace.json', import.meta); +const iframeDevtoolsLog = readJson('../../fixtures/traces/iframe-m79.devtoolslog.json', import.meta); + describe('Metrics: Lantern TTI', () => { const gatherContext = {gatherMode: 'navigation'}; diff --git a/lighthouse-core/test/computed/metrics/lantern-largest-contentful-paint-test.js b/lighthouse-core/test/computed/metrics/lantern-largest-contentful-paint-test.js index 9f8dda5494fa..e5be9fc01e04 100644 --- a/lighthouse-core/test/computed/metrics/lantern-largest-contentful-paint-test.js +++ b/lighthouse-core/test/computed/metrics/lantern-largest-contentful-paint-test.js @@ -6,11 +6,13 @@ import {strict as assert} from 'assert'; -import trace from '../../fixtures/traces/lcp-m78.json'; -import devtoolsLog from '../../fixtures/traces/lcp-m78.devtools.log.json'; +import {readJson} from '../../../../root.js'; import LanternLargestContentfulPaint from '../../../computed/metrics/lantern-largest-contentful-paint.js'; // eslint-disable-line max-len import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; +const trace = readJson('../../fixtures/traces/lcp-m78.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/lcp-m78.devtools.log.json', import.meta); + const URL = getURLArtifactFromDevtoolsLog(devtoolsLog); describe('Metrics: Lantern LCP', () => { it('should compute predicted value', async () => { diff --git a/lighthouse-core/test/computed/metrics/lantern-speed-index-test.js b/lighthouse-core/test/computed/metrics/lantern-speed-index-test.js index d8ed61da7163..357d8e6f206c 100644 --- a/lighthouse-core/test/computed/metrics/lantern-speed-index-test.js +++ b/lighthouse-core/test/computed/metrics/lantern-speed-index-test.js @@ -7,8 +7,10 @@ import constants from '../../../config/constants.js'; import LanternSpeedIndex from '../../../computed/metrics/lantern-speed-index.js'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; -import trace from '../../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; +import {readJson} from '../../../../root.js'; + +const trace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); const defaultThrottling = constants.throttling.mobileSlow4G; const URL = getURLArtifactFromDevtoolsLog(devtoolsLog); diff --git a/lighthouse-core/test/computed/metrics/largest-contentful-paint-all-frames-test.js b/lighthouse-core/test/computed/metrics/largest-contentful-paint-all-frames-test.js index da6c4c1dbac9..3495dedb6449 100644 --- a/lighthouse-core/test/computed/metrics/largest-contentful-paint-all-frames-test.js +++ b/lighthouse-core/test/computed/metrics/largest-contentful-paint-all-frames-test.js @@ -6,13 +6,15 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../../root.js'; import LargestContentfulPaintAllFrames from '../../../computed/metrics/largest-contentful-paint-all-frames.js'; // eslint-disable-line max-len -import traceAllFrames from '../../fixtures/traces/frame-metrics-m89.json'; -import devtoolsLogAllFrames from '../../fixtures/traces/frame-metrics-m89.devtools.log.json'; -import traceMainFrame from '../../fixtures/traces/lcp-m78.json'; -import devtoolsLogMainFrame from '../../fixtures/traces/lcp-m78.devtools.log.json'; -import invalidTrace from '../../fixtures/traces/progressive-app-m60.json'; -import invalidDevtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; + +const traceAllFrames = readJson('../../fixtures/traces/frame-metrics-m89.json', import.meta); +const devtoolsLogAllFrames = readJson('../../fixtures/traces/frame-metrics-m89.devtools.log.json', import.meta); +const traceMainFrame = readJson('../../fixtures/traces/lcp-m78.json', import.meta); +const devtoolsLogMainFrame = readJson('../../fixtures/traces/lcp-m78.devtools.log.json', import.meta); +const invalidTrace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const invalidDevtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); describe('Metrics: LCP from all frames', () => { const gatherContext = {gatherMode: 'navigation'}; diff --git a/lighthouse-core/test/computed/metrics/largest-contentful-paint-test.js b/lighthouse-core/test/computed/metrics/largest-contentful-paint-test.js index 2753ced8fe20..4fb6041958c4 100644 --- a/lighthouse-core/test/computed/metrics/largest-contentful-paint-test.js +++ b/lighthouse-core/test/computed/metrics/largest-contentful-paint-test.js @@ -6,13 +6,15 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../../root.js'; import LargestContentfulPaint from '../../../computed/metrics/largest-contentful-paint.js'; // eslint-disable-line max-len -import trace from '../../fixtures/traces/lcp-m78.json'; -import devtoolsLog from '../../fixtures/traces/lcp-m78.devtools.log.json'; -import invalidTrace from '../../fixtures/traces/progressive-app-m60.json'; -import invalidDevtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; +const trace = readJson('../../fixtures/traces/lcp-m78.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/lcp-m78.devtools.log.json', import.meta); +const invalidTrace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const invalidDevtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); + describe('Metrics: LCP', () => { const gatherContext = {gatherMode: 'navigation'}; diff --git a/lighthouse-core/test/computed/metrics/max-potential-fid-test.js b/lighthouse-core/test/computed/metrics/max-potential-fid-test.js index 5fd4d5b2f4b9..f48028ccfa20 100644 --- a/lighthouse-core/test/computed/metrics/max-potential-fid-test.js +++ b/lighthouse-core/test/computed/metrics/max-potential-fid-test.js @@ -6,11 +6,13 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../../root.js'; import MaxPotentialFID from '../../../computed/metrics/max-potential-fid.js'; -import trace from '../../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; +const trace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); + const URL = getURLArtifactFromDevtoolsLog(devtoolsLog); describe('Metrics: Max Potential FID', () => { diff --git a/lighthouse-core/test/computed/metrics/responsiveness-test.js b/lighthouse-core/test/computed/metrics/responsiveness-test.js index ded878bb4499..c49a522b5087 100644 --- a/lighthouse-core/test/computed/metrics/responsiveness-test.js +++ b/lighthouse-core/test/computed/metrics/responsiveness-test.js @@ -6,10 +6,12 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../../root.js'; import Responsiveness from '../../../computed/metrics/responsiveness.js'; import createTestTrace from '../../create-test-trace.js'; -import interactionTrace from '../../fixtures/traces/timespan-responsiveness-m103.trace.json'; -import noInteractionTrace from '../../fixtures/traces/frame-metrics-m89.json'; + +const interactionTrace = readJson('../../fixtures/traces/timespan-responsiveness-m103.trace.json', import.meta); +const noInteractionTrace = readJson('../../fixtures/traces/frame-metrics-m89.json', import.meta); const childFrameId = 'CAF4634127666E186C9C8B35627DBF0B'; diff --git a/lighthouse-core/test/computed/metrics/speed-index-test.js b/lighthouse-core/test/computed/metrics/speed-index-test.js index 4fd52f7c22d8..0a2cf007a8c9 100644 --- a/lighthouse-core/test/computed/metrics/speed-index-test.js +++ b/lighthouse-core/test/computed/metrics/speed-index-test.js @@ -6,13 +6,15 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../../root.js'; import SpeedIndex from '../../../computed/metrics/speed-index.js'; -import trace from '../../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; -import trace1msLayout from '../../fixtures/traces/speedindex-1ms-layout-m84.trace.json'; -import devtoolsLog1msLayout from '../../fixtures/traces/speedindex-1ms-layout-m84.devtoolslog.json'; // eslint-disable-line max-len import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; +const trace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); +const trace1msLayout = readJson('../../fixtures/traces/speedindex-1ms-layout-m84.trace.json', import.meta); +const devtoolsLog1msLayout = readJson('../../fixtures/traces/speedindex-1ms-layout-m84.devtoolslog.json', import.meta); // eslint-disable-line max-len + describe('Metrics: Speed Index', () => { const gatherContext = {gatherMode: 'navigation'}; diff --git a/lighthouse-core/test/computed/metrics/timing-summary-test.js b/lighthouse-core/test/computed/metrics/timing-summary-test.js index 0ea8ac1d6079..a001b5ef30c8 100644 --- a/lighthouse-core/test/computed/metrics/timing-summary-test.js +++ b/lighthouse-core/test/computed/metrics/timing-summary-test.js @@ -4,9 +4,12 @@ * 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. */ +import {readJson} from '../../../../root.js'; import TimingSummary from '../../../computed/metrics/timing-summary.js'; -import trace from '../../fixtures/traces/frame-metrics-m90.json'; -import devtoolsLog from '../../fixtures/traces/frame-metrics-m90.devtools.log.json'; + +const trace = readJson('../../fixtures/traces/frame-metrics-m90.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/frame-metrics-m90.devtools.log.json', import.meta); + describe('Timing summary', () => { it('contains the correct data', async () => { const gatherContext = {gatherMode: 'navigation'}; diff --git a/lighthouse-core/test/computed/metrics/total-blocking-time-test.js b/lighthouse-core/test/computed/metrics/total-blocking-time-test.js index 1b5addfcf604..2892d17ea2b0 100644 --- a/lighthouse-core/test/computed/metrics/total-blocking-time-test.js +++ b/lighthouse-core/test/computed/metrics/total-blocking-time-test.js @@ -5,10 +5,12 @@ */ import TotalBlockingTime from '../../../computed/metrics/total-blocking-time.js'; -import trace from '../../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../../fixtures/traces/progressive-app-m60.devtools.log.json'; import {calculateSumOfBlockingTime} from '../../../computed/metrics/tbt-utils.js'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; +import {readJson} from '../../../../root.js'; + +const trace = readJson('../../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); const URL = getURLArtifactFromDevtoolsLog(devtoolsLog); diff --git a/lighthouse-core/test/computed/network-analysis-test.js b/lighthouse-core/test/computed/network-analysis-test.js index d6c1a9ac4f9e..ee905cb8de03 100644 --- a/lighthouse-core/test/computed/network-analysis-test.js +++ b/lighthouse-core/test/computed/network-analysis-test.js @@ -4,8 +4,10 @@ * 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. */ +import {readJson} from '../../../root.js'; import NetworkAnalysis from '../../computed/network-analysis.js'; -import acceptableDevToolsLog from '../fixtures/traces/progressive-app-m60.devtools.log.json'; + +const acceptableDevToolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); describe('Network analysis computed', () => { it('should return network analysis', async () => { diff --git a/lighthouse-core/test/computed/page-dependency-graph-test.js b/lighthouse-core/test/computed/page-dependency-graph-test.js index 65c3e0a0d0b2..4c299fda5a0e 100644 --- a/lighthouse-core/test/computed/page-dependency-graph-test.js +++ b/lighthouse-core/test/computed/page-dependency-graph-test.js @@ -9,11 +9,13 @@ import {strict as assert} from 'assert'; import PageDependencyGraph from '../../computed/page-dependency-graph.js'; import BaseNode from '../../lib/dependency-graph/base-node.js'; import NetworkRequest from '../../lib/network-request.js'; -import sampleTrace from '../fixtures/traces/iframe-m79.trace.json'; -import sampleDevtoolsLog from '../fixtures/traces/iframe-m79.devtoolslog.json'; import {getURLArtifactFromDevtoolsLog} from '../test-utils.js'; import NetworkRecorder from '../../lib/network-recorder.js'; import networkRecordsToDevtoolsLog from '../network-records-to-devtools-log.js'; +import {readJson} from '../../../root.js'; + +const sampleTrace = readJson('../fixtures/traces/iframe-m79.trace.json', import.meta); +const sampleDevtoolsLog = readJson('../fixtures/traces/iframe-m79.devtoolslog.json', import.meta); function createRequest( requestId, diff --git a/lighthouse-core/test/computed/processed-navigation-test.js b/lighthouse-core/test/computed/processed-navigation-test.js index 629ce6b2d8d8..55ea2476926b 100644 --- a/lighthouse-core/test/computed/processed-navigation-test.js +++ b/lighthouse-core/test/computed/processed-navigation-test.js @@ -6,9 +6,11 @@ import ProcessedTrace from '../../computed/processed-trace.js'; import ProcessedNavigation from '../../computed/processed-navigation.js'; -import pwaTrace from '../fixtures/traces/progressive-app-m60.json'; -import noFCPtrace from '../fixtures/traces/airhorner_no_fcp.json'; -import noNavStartTrace from '../fixtures/traces/no_navstart_event.json'; +import {readJson} from '../../../root.js'; + +const pwaTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); +const noFCPtrace = readJson('../fixtures/traces/airhorner_no_fcp.json', import.meta); +const noNavStartTrace = readJson('../fixtures/traces/no_navstart_event.json', import.meta); describe('ProcessedTrace', () => { it('computes the artifact', async () => { diff --git a/lighthouse-core/test/computed/processed-trace-test.js b/lighthouse-core/test/computed/processed-trace-test.js index 76bbacd9e679..119e41498d71 100644 --- a/lighthouse-core/test/computed/processed-trace-test.js +++ b/lighthouse-core/test/computed/processed-trace-test.js @@ -4,8 +4,10 @@ * 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. */ +import {readJson} from '../../../root.js'; import ProcessedTrace from '../../computed/processed-trace.js'; -import pwaTrace from '../fixtures/traces/progressive-app-m60.json'; + +const pwaTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); describe('ProcessedTrace', () => { it('computes the artifact', async () => { diff --git a/lighthouse-core/test/computed/screenshots-test.js b/lighthouse-core/test/computed/screenshots-test.js index 682c62116521..690f9575b274 100644 --- a/lighthouse-core/test/computed/screenshots-test.js +++ b/lighthouse-core/test/computed/screenshots-test.js @@ -6,8 +6,10 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../root.js'; import Screenshots from '../../computed/screenshots.js'; -import pwaTrace from '../fixtures/traces/progressive-app.json'; + +const pwaTrace = readJson('../fixtures/traces/progressive-app.json', import.meta); describe('Screenshot computed artifact', () => { it('returns an artifact for a real trace', () => { diff --git a/lighthouse-core/test/computed/speedline-test.js b/lighthouse-core/test/computed/speedline-test.js index 32a981a51a3e..eed610d0d8c1 100644 --- a/lighthouse-core/test/computed/speedline-test.js +++ b/lighthouse-core/test/computed/speedline-test.js @@ -6,11 +6,12 @@ import {strict as assert} from 'assert'; -import pwaTrace from '../fixtures/traces/progressive-app.json'; -import threeFrameTrace from '../fixtures/traces/threeframes-blank_content_more.json'; import Speedline from '../../computed/speedline.js'; import {readJson} from '../../../root.js'; +const pwaTrace = readJson('../fixtures/traces/progressive-app.json', import.meta); +const threeFrameTrace = readJson('../fixtures/traces/threeframes-blank_content_more.json', import.meta); + describe('Speedline gatherer', () => { it('returns an error message on faulty trace data', () => { const context = {computedCache: new Map()}; diff --git a/lighthouse-core/test/computed/trace-of-tab-test.js b/lighthouse-core/test/computed/trace-of-tab-test.js index 0b8318fdf202..42c0b1bebf69 100644 --- a/lighthouse-core/test/computed/trace-of-tab-test.js +++ b/lighthouse-core/test/computed/trace-of-tab-test.js @@ -4,8 +4,10 @@ * 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. */ +import {readJson} from '../../../root.js'; import TraceOfTab from '../../computed/trace-of-tab.js'; -import pwaTrace from '../fixtures/traces/progressive-app-m60.json'; + +const pwaTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); describe('TraceOfTab', () => { it('computes the artifact', async () => { diff --git a/lighthouse-core/test/gather/gather-runner-test.js b/lighthouse-core/test/gather/gather-runner-test.js index 58e610b762e0..e7252a589e56 100644 --- a/lighthouse-core/test/gather/gather-runner-test.js +++ b/lighthouse-core/test/gather/gather-runner-test.js @@ -11,7 +11,6 @@ import {jest} from '@jest/globals'; import Gatherer from '../../gather/gatherers/gatherer.js'; // import GathererRunner_ from '../../gather/gather-runner.js'; // import Config from '../../config/config.js'; -import unresolvedPerfLog from './../fixtures/unresolved-perflog.json'; import LHError from '../../lib/lh-error.js'; import networkRecordsToDevtoolsLog from '../network-records-to-devtools-log.js'; // import Driver from '../../gather/driver.js'; @@ -26,6 +25,9 @@ import { } from '../test-utils.js'; import fakeDriver from './fake-driver.js'; import {createCommonjsRefs} from '../../scripts/esm-utils.js'; +import {readJson} from '../../../root.js'; + +const unresolvedPerfLog = readJson('./../fixtures/unresolved-perflog.json', import.meta); const {require} = createCommonjsRefs(import.meta); diff --git a/lighthouse-core/test/gather/gatherers/image-elements-test.js b/lighthouse-core/test/gather/gatherers/image-elements-test.js index 910f0f62831a..35a32d14ae43 100644 --- a/lighthouse-core/test/gather/gatherers/image-elements-test.js +++ b/lighthouse-core/test/gather/gatherers/image-elements-test.js @@ -6,14 +6,15 @@ import {jest} from '@jest/globals'; +import {readJson} from '../../../../root.js'; import ImageElements from '../../../gather/gatherers/image-elements.js'; import NetworkRecorder from '../../../lib/network-recorder.js'; import {createMockContext, createMockDriver, createMockSession} from '../../fraggle-rock/gather/mock-driver.js'; import {fnAny} from '../../test-utils.js'; -import devtoolsLog from '../../fixtures/traces/lcp-m78.devtools.log.json'; -// @ts-expect-error +const devtoolsLog = readJson('../../fixtures/traces/lcp-m78.devtools.log.json', import.meta); + const networkRecords = NetworkRecorder.recordsFromLogs(devtoolsLog); jest.useFakeTimers(); @@ -309,7 +310,6 @@ describe('FR compat', () => { mockContext.driver._executionContext.evaluate.mockReturnValue([mockElement()]); const artifact = await gatherer.afterPass(mockContext.asLegacyContext(), { - // @ts-expect-error devtoolsLog, networkRecords, }); diff --git a/lighthouse-core/test/gather/gatherers/main-document-content-test.js b/lighthouse-core/test/gather/gatherers/main-document-content-test.js index 505971a0b693..b3e0ca46562c 100644 --- a/lighthouse-core/test/gather/gatherers/main-document-content-test.js +++ b/lighthouse-core/test/gather/gatherers/main-document-content-test.js @@ -4,19 +4,19 @@ * 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. */ +import {readJson} from '../../../../root.js'; import MainDocumentContent from '../../../gather/gatherers/main-document-content.js'; import NetworkRecorder from '../../../lib/network-recorder.js'; import {createMockContext} from '../../fraggle-rock/gather/mock-driver.js'; import {getURLArtifactFromDevtoolsLog} from '../../test-utils.js'; -import devtoolsLog from '../../fixtures/traces/lcp-m78.devtools.log.json'; -// @ts-expect-error +const devtoolsLog = readJson('../../fixtures/traces/lcp-m78.devtools.log.json', import.meta); + const URL = getURLArtifactFromDevtoolsLog(devtoolsLog); describe('FR compat', () => { it('uses loadData in legacy mode', async () => { const gatherer = new MainDocumentContent(); - // @ts-expect-error const networkRecords = NetworkRecorder.recordsFromLogs(devtoolsLog); const mockContext = createMockContext(); mockContext.baseArtifacts.URL = URL; @@ -25,7 +25,6 @@ describe('FR compat', () => { const artifact = await gatherer.afterPass( mockContext.asLegacyContext(), - // @ts-expect-error {devtoolsLog, networkRecords} ); @@ -42,7 +41,6 @@ describe('FR compat', () => { /** @type {LH.Gatherer.FRTransitionalContext<'DevtoolsLog'>} */ const context = { ...mockContext.asContext(), - // @ts-expect-error dependencies: {DevtoolsLog: devtoolsLog}, }; diff --git a/lighthouse-core/test/gather/gatherers/network-user-agent-test.js b/lighthouse-core/test/gather/gatherers/network-user-agent-test.js index 42c4ee0063bc..4e3fd06ed39b 100644 --- a/lighthouse-core/test/gather/gatherers/network-user-agent-test.js +++ b/lighthouse-core/test/gather/gatherers/network-user-agent-test.js @@ -4,8 +4,10 @@ * 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. */ +import {readJson} from '../../../../root.js'; import NetworkUserAgent from '../../../gather/gatherers/network-user-agent.js'; -import devtoolsLog from '../../fixtures/traces/lcp-m78.devtools.log.json'; + +const devtoolsLog = readJson('../../fixtures/traces/lcp-m78.devtools.log.json', import.meta); describe('.getNetworkUserAgent', () => { it('should return empty string when no network events available', async () => { @@ -14,7 +16,6 @@ describe('.getNetworkUserAgent', () => { }); it('should return the user agent that was used to make requests', async () => { - // @ts-expect-error const result = await NetworkUserAgent.getNetworkUserAgent(devtoolsLog); // eslint-disable-next-line max-len expect(result).toEqual('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36'); diff --git a/lighthouse-core/test/gather/gatherers/trace-elements-test.js b/lighthouse-core/test/gather/gatherers/trace-elements-test.js index 059ada3d8736..7b7b201311b0 100644 --- a/lighthouse-core/test/gather/gatherers/trace-elements-test.js +++ b/lighthouse-core/test/gather/gatherers/trace-elements-test.js @@ -12,7 +12,9 @@ import Connection from '../../../gather/connections/connection.js'; import createTestTrace from '../../create-test-trace.js'; import {createMockSendCommandFn, createMockOnFn} from '../mock-commands.js'; import {flushAllTimersAndMicrotasks, fnAny} from '../../test-utils.js'; -import animationTrace from '../../fixtures/traces/animation.json'; +import {readJson} from '../../../../root.js'; + +const animationTrace = readJson('../../fixtures/traces/animation.json', import.meta); jest.useFakeTimers(); diff --git a/lighthouse-core/test/index-test.js b/lighthouse-core/test/index-test.js index ec24ca511507..b09bcdf72144 100644 --- a/lighthouse-core/test/index-test.js +++ b/lighthouse-core/test/index-test.js @@ -6,9 +6,10 @@ import {strict as assert} from 'assert'; -import pkg from '../../package.json'; import lighthouse from '../index.js'; -import {LH_ROOT} from '../../root.js'; +import {LH_ROOT, readJson} from '../../root.js'; + +const pkg = readJson('package.json'); const {legacyNavigation} = lighthouse; const TEST_DIR = `${LH_ROOT}/lighthouse-core/test`; diff --git a/lighthouse-core/test/lib/arbitrary-equality-map-test.js b/lighthouse-core/test/lib/arbitrary-equality-map-test.js index 2ee66375611a..d212dedb539e 100644 --- a/lighthouse-core/test/lib/arbitrary-equality-map-test.js +++ b/lighthouse-core/test/lib/arbitrary-equality-map-test.js @@ -6,8 +6,10 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../root.js'; import ArbitraryEqualityMap from '../../lib/arbitrary-equality-map.js'; -import trace from '../fixtures/traces/progressive-app-m60.json'; + +const trace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); describe('ArbitraryEqualityMap', () => { it('creates a map', () => { diff --git a/lighthouse-core/test/lib/asset-saver-test.js b/lighthouse-core/test/lib/asset-saver-test.js index 7f1bf5343fb9..ca726e071842 100644 --- a/lighthouse-core/test/lib/asset-saver-test.js +++ b/lighthouse-core/test/lib/asset-saver-test.js @@ -10,13 +10,15 @@ import fs from 'fs'; import assetSaver from '../../lib/asset-saver.js'; import Metrics from '../../lib/traces/pwmetrics-events.js'; import LHError from '../../lib/lh-error.js'; -import traceEvents from '../fixtures/traces/progressive-app.json'; -import dbwTrace from '../results/artifacts/defaultPass.trace.json'; -import dbwResults from '../results/sample_v2.json'; import Audit from '../../audits/audit.js'; import {createCommonjsRefs} from '../../scripts/esm-utils.js'; -import fullTraceObj from '../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../fixtures/traces/progressive-app-m60.devtools.log.json'; +import {readJson} from '../../../root.js'; + +const traceEvents = readJson('../fixtures/traces/progressive-app.json', import.meta); +const dbwTrace = readJson('../results/artifacts/defaultPass.trace.json', import.meta); +const dbwResults = readJson('../results/sample_v2.json', import.meta); +const fullTraceObj = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); const {__dirname} = createCommonjsRefs(import.meta); diff --git a/lighthouse-core/test/lib/dependency-graph/simulator/network-analyzer-test.js b/lighthouse-core/test/lib/dependency-graph/simulator/network-analyzer-test.js index 82da973a76f2..5e6e0a568828 100644 --- a/lighthouse-core/test/lib/dependency-graph/simulator/network-analyzer-test.js +++ b/lighthouse-core/test/lib/dependency-graph/simulator/network-analyzer-test.js @@ -8,8 +8,10 @@ import {strict as assert} from 'assert'; import NetworkAnalyzer from '../../../../lib/dependency-graph/simulator/network-analyzer.js'; import NetworkRecords from '../../../../computed/network-records.js'; -import devtoolsLog from '../../../fixtures/traces/progressive-app-m60.devtools.log.json'; -import devtoolsLogWithRedirect from '../../../fixtures/traces/site-with-redirect.devtools.log.json'; +import {readJson} from '../../../../../root.js'; + +const devtoolsLog = readJson('../../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); +const devtoolsLogWithRedirect = readJson('../../../fixtures/traces/site-with-redirect.devtools.log.json', import.meta); describe('DependencyGraph/Simulator/NetworkAnalyzer', () => { let recordId; diff --git a/lighthouse-core/test/lib/dependency-graph/simulator/simulator-test.js b/lighthouse-core/test/lib/dependency-graph/simulator/simulator-test.js index 2e20b9e04503..55c4c8f54e65 100644 --- a/lighthouse-core/test/lib/dependency-graph/simulator/simulator-test.js +++ b/lighthouse-core/test/lib/dependency-graph/simulator/simulator-test.js @@ -12,8 +12,10 @@ import Simulator from '../../../../lib/dependency-graph/simulator/simulator.js'; import DNSCache from '../../../../lib/dependency-graph/simulator/dns-cache.js'; import PageDependencyGraph from '../../../../computed/page-dependency-graph.js'; import {getURLArtifactFromDevtoolsLog} from '../../../test-utils.js'; -import pwaTrace from '../../../fixtures/traces/progressive-app-m60.json'; -import pwaDevtoolsLog from '../../../fixtures/traces/progressive-app-m60.devtools.log.json'; +import {readJson} from '../../../../../root.js'; + +const pwaTrace = readJson('../../../fixtures/traces/progressive-app-m60.json', import.meta); +const pwaDevtoolsLog = readJson('../../../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); let nextRequestId = 1; let nextTid = 1; diff --git a/lighthouse-core/test/lib/manifest-parser-test.js b/lighthouse-core/test/lib/manifest-parser-test.js index b68447472158..85ec6a59d5cb 100644 --- a/lighthouse-core/test/lib/manifest-parser-test.js +++ b/lighthouse-core/test/lib/manifest-parser-test.js @@ -6,8 +6,10 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../root.js'; import manifestParser from '../../lib/manifest-parser.js'; -import manifestStub from '../fixtures/manifest.json'; + +const manifestStub = readJson('../fixtures/manifest.json', import.meta); const EXAMPLE_MANIFEST_URL = 'https://example.com/manifest.json'; const EXAMPLE_DOC_URL = 'https://example.com/index.html'; diff --git a/lighthouse-core/test/lib/minify-devtoolslog-test.js b/lighthouse-core/test/lib/minify-devtoolslog-test.js index bf8b2eef823f..fa6cd7589832 100644 --- a/lighthouse-core/test/lib/minify-devtoolslog-test.js +++ b/lighthouse-core/test/lib/minify-devtoolslog-test.js @@ -5,9 +5,11 @@ */ import {minifyDevtoolsLog} from '../../lib/minify-devtoolslog.js'; -import trace from '../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../fixtures/traces/progressive-app-m60.devtools.log.json'; import MetricsAudit from '../../audits/metrics.js'; +import {readJson} from '../../../root.js'; + +const trace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); describe('minify-devtoolslog', () => { it('has identical metrics to unminified', async () => { diff --git a/lighthouse-core/test/lib/minify-trace-test.js b/lighthouse-core/test/lib/minify-trace-test.js index 644950aaac61..5ca05f3fdd42 100644 --- a/lighthouse-core/test/lib/minify-trace-test.js +++ b/lighthouse-core/test/lib/minify-trace-test.js @@ -5,9 +5,11 @@ */ import {minifyTrace} from '../../lib/minify-trace.js'; -import trace from '../fixtures/traces/progressive-app-m60.json'; -import devtoolsLog from '../fixtures/traces/progressive-app-m60.devtools.log.json'; import MetricsAudit from '../../audits/metrics.js'; +import {readJson} from '../../../root.js'; + +const trace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); +const devtoolsLog = readJson('../fixtures/traces/progressive-app-m60.devtools.log.json', import.meta); describe('minify-trace', () => { it('has identical metrics to unminified', async () => { diff --git a/lighthouse-core/test/lib/network-recorder-test.js b/lighthouse-core/test/lib/network-recorder-test.js index 7de08a195b61..f291cb762fc0 100644 --- a/lighthouse-core/test/lib/network-recorder-test.js +++ b/lighthouse-core/test/lib/network-recorder-test.js @@ -6,13 +6,15 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../root.js'; import NetworkRecorder from '../../lib/network-recorder.js'; import networkRecordsToDevtoolsLog from '../network-records-to-devtools-log.js'; -import devtoolsLogItems from '../fixtures/artifacts/perflog/defaultPass.devtoolslog.json'; -import prefetchedScriptDevtoolsLog from '../fixtures/prefetched-script.devtoolslog.json'; -import redirectsDevtoolsLog from '../fixtures/wikipedia-redirect.devtoolslog.json'; -import redirectsScriptDevtoolsLog from '../fixtures/redirects-from-script.devtoolslog.json'; -import lrRequestDevtoolsLog from '../fixtures/lr.devtoolslog.json'; + +const devtoolsLogItems = readJson('../fixtures/artifacts/perflog/defaultPass.devtoolslog.json', import.meta); +const prefetchedScriptDevtoolsLog = readJson('../fixtures/prefetched-script.devtoolslog.json', import.meta); +const redirectsDevtoolsLog = readJson('../fixtures/wikipedia-redirect.devtoolslog.json', import.meta); +const redirectsScriptDevtoolsLog = readJson('../fixtures/redirects-from-script.devtoolslog.json', import.meta); +const lrRequestDevtoolsLog = readJson('../fixtures/lr.devtoolslog.json', import.meta); describe('network recorder', function() { it('recordsFromLogs expands into records', function() { diff --git a/lighthouse-core/test/lib/proto-preprocessor-test.js b/lighthouse-core/test/lib/proto-preprocessor-test.js index 6e6d311b6c2a..468e28cd93f9 100644 --- a/lighthouse-core/test/lib/proto-preprocessor-test.js +++ b/lighthouse-core/test/lib/proto-preprocessor-test.js @@ -6,7 +6,9 @@ import {getProtoRoundTrip} from '../test-utils.js'; import {processForProto} from '../../lib/proto-preprocessor.js'; -import sampleJson from '../results/sample_v2.json'; +import {readJson} from '../../../root.js'; + +const sampleJson = readJson('../results/sample_v2.json', import.meta); const {describeIfProtoExists, sampleResultsRoundtripStr} = getProtoRoundTrip(); const roundTripJson = sampleResultsRoundtripStr && JSON.parse(sampleResultsRoundtripStr); diff --git a/lighthouse-core/test/lib/tracehouse/cpu-profile-model-test.js b/lighthouse-core/test/lib/tracehouse/cpu-profile-model-test.js index df4a75566c92..7bfe91f1382b 100644 --- a/lighthouse-core/test/lib/tracehouse/cpu-profile-model-test.js +++ b/lighthouse-core/test/lib/tracehouse/cpu-profile-model-test.js @@ -7,8 +7,10 @@ import CpuProfileModel from '../../../lib/tracehouse/cpu-profile-model.js'; import TraceProcessor from '../../../lib/tracehouse/trace-processor.js'; import MainThreadTasks from '../../../lib/tracehouse/main-thread-tasks.js'; -import profilerTrace from '../../fixtures/traces/cpu-profiler-m86.trace.json'; import CpuProfilerModel from '../../../lib/tracehouse/cpu-profile-model.js'; +import {readJson} from '../../../../root.js'; + +const profilerTrace = readJson('../../fixtures/traces/cpu-profiler-m86.trace.json', import.meta); describe('CPU Profiler Model', () => { /** @type {LH.TraceCpuProfile} */ diff --git a/lighthouse-core/test/lib/tracehouse/main-thread-tasks-test.js b/lighthouse-core/test/lib/tracehouse/main-thread-tasks-test.js index 3b78692073e7..f54395b2959b 100644 --- a/lighthouse-core/test/lib/tracehouse/main-thread-tasks-test.js +++ b/lighthouse-core/test/lib/tracehouse/main-thread-tasks-test.js @@ -9,9 +9,11 @@ import {strict as assert} from 'assert'; import MainThreadTasks from '../../../lib/tracehouse/main-thread-tasks.js'; import TraceProcessor from '../../../lib/tracehouse/trace-processor.js'; import {taskGroups} from '../../../lib/tracehouse/task-groups.js'; -import pwaTrace from '../../fixtures/traces/progressive-app.json'; -import noTracingStartedTrace from '../../fixtures/traces/no-tracingstarted-m74.json'; import TracingProcessor from '../../../lib/tracehouse/trace-processor.js'; +import {readJson} from '../../../../root.js'; + +const pwaTrace = readJson('../../fixtures/traces/progressive-app.json', import.meta); +const noTracingStartedTrace = readJson('../../fixtures/traces/no-tracingstarted-m74.json', import.meta); describe('Main Thread Tasks', () => { const pid = 1; diff --git a/lighthouse-core/test/lib/tracehouse/task-summary-test.js b/lighthouse-core/test/lib/tracehouse/task-summary-test.js index 50ab658c2ce6..09dd90c72492 100644 --- a/lighthouse-core/test/lib/tracehouse/task-summary-test.js +++ b/lighthouse-core/test/lib/tracehouse/task-summary-test.js @@ -11,11 +11,13 @@ import { } from '../../../lib/tracehouse/task-summary.js'; import NetworkRecorder from '../../../lib/network-recorder.js'; import MainThreadTasks from '../../../lib/tracehouse/main-thread-tasks.js'; -import ampTrace from '../../fixtures/traces/amp-m86.trace.json'; -import ampDevtoolsLog from '../../fixtures/traces/amp-m86.devtoolslog.json'; import TraceProcessor from '../../../lib/tracehouse/trace-processor.js'; import networkRecordsToDevtoolsLog from '../../network-records-to-devtools-log.js'; import {taskGroups} from '../../../lib/tracehouse/task-groups.js'; +import {readJson} from '../../../../root.js'; + +const ampTrace = readJson('../../fixtures/traces/amp-m86.trace.json', import.meta); +const ampDevtoolsLog = readJson('../../fixtures/traces/amp-m86.devtoolslog.json', import.meta); function getTasks(trace) { const {mainThreadEvents, frames, timestamps} = TraceProcessor.processTrace(trace); diff --git a/lighthouse-core/test/lib/tracehouse/trace-processor-test.js b/lighthouse-core/test/lib/tracehouse/trace-processor-test.js index 8f41e2167b6c..6e2ea71968f1 100644 --- a/lighthouse-core/test/lib/tracehouse/trace-processor-test.js +++ b/lighthouse-core/test/lib/tracehouse/trace-processor-test.js @@ -6,21 +6,23 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../../root.js'; import TraceProcessor from '../../../lib/tracehouse/trace-processor.js'; import createTestTrace from '../../create-test-trace.js'; -import pwaTrace from '../../fixtures/traces/progressive-app.json'; -import badNavStartTrace from '../../fixtures/traces/bad-nav-start-ts.json'; -import lateTracingStartedTrace from '../../fixtures/traces/tracingstarted-after-navstart.json'; -import noTracingStartedTrace from '../../fixtures/traces/no-tracingstarted-m74.json'; -import preactTrace from '../../fixtures/traces/preactjs.com_ts_of_undefined.json'; -import noFMPtrace from '../../fixtures/traces/no_fmp_event.json'; -import noFCPtrace from '../../fixtures/traces/airhorner_no_fcp.json'; -import timespanTrace from '../../fixtures/traces/timespan-trace-m91.json'; -import noNavStartTrace from '../../fixtures/traces/no_navstart_event.json'; -import backgroundTabTrace from '../../fixtures/traces/backgrounded-tab-missing-paints.json'; -import lcpTrace from '../../fixtures/traces/lcp-m78.json'; -import lcpAllFramesTrace from '../../fixtures/traces/frame-metrics-m89.json'; -import startedAfterNavstartTrace from '../../fixtures/traces/tracingstarted-after-navstart.json'; + +const pwaTrace = readJson('../../fixtures/traces/progressive-app.json', import.meta); +const badNavStartTrace = readJson('../../fixtures/traces/bad-nav-start-ts.json', import.meta); +const lateTracingStartedTrace = readJson('../../fixtures/traces/tracingstarted-after-navstart.json', import.meta); +const noTracingStartedTrace = readJson('../../fixtures/traces/no-tracingstarted-m74.json', import.meta); +const preactTrace = readJson('../../fixtures/traces/preactjs.com_ts_of_undefined.json', import.meta); +const noFMPtrace = readJson('../../fixtures/traces/no_fmp_event.json', import.meta); +const noFCPtrace = readJson('../../fixtures/traces/airhorner_no_fcp.json', import.meta); +const timespanTrace = readJson('../../fixtures/traces/timespan-trace-m91.json', import.meta); +const noNavStartTrace = readJson('../../fixtures/traces/no_navstart_event.json', import.meta); +const backgroundTabTrace = readJson('../../fixtures/traces/backgrounded-tab-missing-paints.json', import.meta); +const lcpTrace = readJson('../../fixtures/traces/lcp-m78.json', import.meta); +const lcpAllFramesTrace = readJson('../../fixtures/traces/frame-metrics-m89.json', import.meta); +const startedAfterNavstartTrace = readJson('../../fixtures/traces/tracingstarted-after-navstart.json', import.meta); describe('TraceProcessor', () => { describe('_riskPercentiles', () => { diff --git a/lighthouse-core/test/lib/traces/pwmetrics-events-test.js b/lighthouse-core/test/lib/traces/pwmetrics-events-test.js index 042209b7bc3f..f40a359a7b76 100644 --- a/lighthouse-core/test/lib/traces/pwmetrics-events-test.js +++ b/lighthouse-core/test/lib/traces/pwmetrics-events-test.js @@ -6,9 +6,11 @@ import {strict as assert} from 'assert'; +import {readJson} from '../../../../root.js'; import Metrics from '../../../lib/traces/pwmetrics-events.js'; -import dbwTrace from '../../results/artifacts/defaultPass.trace.json'; -import dbwResults from '../../results/sample_v2.json'; + +const dbwTrace = readJson('../../results/artifacts/defaultPass.trace.json', import.meta); +const dbwResults = readJson('../../results/sample_v2.json', import.meta); describe('metrics events class', () => { it('exposes metric definitions', () => { diff --git a/lighthouse-core/test/network-records-to-devtools-log-test.js b/lighthouse-core/test/network-records-to-devtools-log-test.js index 771ccb33b85e..ff7183a30232 100644 --- a/lighthouse-core/test/network-records-to-devtools-log-test.js +++ b/lighthouse-core/test/network-records-to-devtools-log-test.js @@ -5,8 +5,10 @@ */ import NetworkRecorder from '../../lighthouse-core/lib/network-recorder.js'; +import {readJson} from '../../root.js'; import networkRecordsToDevtoolsLog from './network-records-to-devtools-log.js'; -import lcpDevtoolsLog from './fixtures/traces/lcp-m78.devtools.log.json'; + +const lcpDevtoolsLog = readJson('./fixtures/traces/lcp-m78.devtools.log.json', import.meta); describe('networkRecordsToDevtoolsLog', () => { it('should generate the four messages per request', () => { diff --git a/lighthouse-core/test/sample-json-test.js b/lighthouse-core/test/sample-json-test.js index a084ae22f857..ec9c9cd2bf34 100644 --- a/lighthouse-core/test/sample-json-test.js +++ b/lighthouse-core/test/sample-json-test.js @@ -4,7 +4,9 @@ * 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. */ -import sampleJson from './results/sample_v2.json'; +import {readJson} from '../../root.js'; + +const sampleJson = readJson('./results/sample_v2.json', import.meta); describe('Sample JSON', () => { /** @type {LH.Result} */ diff --git a/report/test/renderer/category-renderer-test.js b/report/test/renderer/category-renderer-test.js index 1c435871fb27..11f214aa0db2 100644 --- a/report/test/renderer/category-renderer-test.js +++ b/report/test/renderer/category-renderer-test.js @@ -13,7 +13,9 @@ import {I18n} from '../../renderer/i18n.js'; import {DOM} from '../../renderer/dom.js'; import {DetailsRenderer} from '../../renderer/details-renderer.js'; import {CategoryRenderer} from '../../renderer/category-renderer.js'; -import sampleResultsOrig from '../../../lighthouse-core/test/results/sample_v2.json'; +import {readJson} from '../../../root.js'; + +const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta); describe('CategoryRenderer', () => { let renderer; diff --git a/report/test/renderer/performance-category-renderer-test.js b/report/test/renderer/performance-category-renderer-test.js index 70b610dd8037..5b69f6e318ce 100644 --- a/report/test/renderer/performance-category-renderer-test.js +++ b/report/test/renderer/performance-category-renderer-test.js @@ -14,7 +14,9 @@ import URL from '../../../lighthouse-core/lib/url-shim.js'; import {DOM} from '../../renderer/dom.js'; import {DetailsRenderer} from '../../renderer/details-renderer.js'; import {PerformanceCategoryRenderer} from '../../renderer/performance-category-renderer.js'; -import sampleResultsOrig from '../../../lighthouse-core/test/results/sample_v2.json'; +import {readJson} from '../../../root.js'; + +const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta); describe('PerfCategoryRenderer', () => { let category; diff --git a/report/test/renderer/pwa-category-renderer-test.js b/report/test/renderer/pwa-category-renderer-test.js index 0110b585eede..915a9fb2a6c1 100644 --- a/report/test/renderer/pwa-category-renderer-test.js +++ b/report/test/renderer/pwa-category-renderer-test.js @@ -13,7 +13,9 @@ import {I18n} from '../../renderer/i18n.js'; import {DOM} from '../../renderer/dom.js'; import {DetailsRenderer} from '../../renderer/details-renderer.js'; import {PwaCategoryRenderer} from '../../renderer/pwa-category-renderer.js'; -import sampleResultsOrig from '../../../lighthouse-core/test/results/sample_v2.json'; +import {readJson} from '../../../root.js'; + +const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta); describe('PwaCategoryRenderer', () => { let category; diff --git a/report/test/renderer/report-renderer-axe-test.js b/report/test/renderer/report-renderer-axe-test.js index c0820345540f..6539825b0907 100644 --- a/report/test/renderer/report-renderer-axe-test.js +++ b/report/test/renderer/report-renderer-axe-test.js @@ -6,9 +6,11 @@ import puppeteer from 'puppeteer'; -import sampleResults from '../../../lighthouse-core/test/results/sample_v2.json'; import reportGenerator from '../../generator/report-generator.js'; import axeLib from '../../../lighthouse-core/lib/axe.js'; +import {readJson} from '../../../root.js'; + +const sampleResults = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta); describe('ReportRendererAxe', () => { describe('with aXe', () => { diff --git a/report/test/renderer/report-renderer-test.js b/report/test/renderer/report-renderer-test.js index 47fbacd98206..230ab5c5e523 100644 --- a/report/test/renderer/report-renderer-test.js +++ b/report/test/renderer/report-renderer-test.js @@ -15,7 +15,9 @@ import {DOM} from '../../renderer/dom.js'; import {DetailsRenderer} from '../../renderer/details-renderer.js'; import {CategoryRenderer} from '../../renderer/category-renderer.js'; import {ReportRenderer} from '../../renderer/report-renderer.js'; -import sampleResultsOrig from '../../../lighthouse-core/test/results/sample_v2.json'; +import {readJson} from '../../../root.js'; + +const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta); const TIMESTAMP_REGEX = /\d+, \d{4}.*\d+:\d+/; diff --git a/report/test/renderer/report-ui-features-test.js b/report/test/renderer/report-ui-features-test.js index 520a4141e35a..45a6dfbc7186 100644 --- a/report/test/renderer/report-ui-features-test.js +++ b/report/test/renderer/report-ui-features-test.js @@ -16,7 +16,9 @@ import {DetailsRenderer} from '../../renderer/details-renderer.js'; import {ReportUIFeatures} from '../../renderer/report-ui-features.js'; import {CategoryRenderer} from '../../renderer/category-renderer.js'; import {ReportRenderer} from '../../renderer/report-renderer.js'; -import sampleResultsOrig from '../../../lighthouse-core/test/results/sample_v2.json'; +import {readJson} from '../../../root.js'; + +const sampleResultsOrig = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta); describe('ReportUIFeatures', () => { let sampleResults; diff --git a/report/test/renderer/util-test.js b/report/test/renderer/util-test.js index 6584c8ef61c4..9762cf4c9d70 100644 --- a/report/test/renderer/util-test.js +++ b/report/test/renderer/util-test.js @@ -8,7 +8,9 @@ import {strict as assert} from 'assert'; import {Util} from '../../renderer/util.js'; import {I18n} from '../../renderer/i18n.js'; -import sampleResult from '../../../lighthouse-core/test/results/sample_v2.json'; +import {readJson} from '../../../root.js'; + +const sampleResult = readJson('../../../lighthouse-core/test/results/sample_v2.json', import.meta); describe('util helpers', () => { beforeEach(() => {