Skip to content

Commit

Permalink
tests(lantern): refactor to DevTools test convention (#16072)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed Jun 12, 2024
1 parent d438037 commit 6859c5f
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ third-party/**
**/*.d.cts

page-functions-test-case*out*.js
# TODO(15841): remove when importing Lantern from npm
core/lib/lantern/**/*.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import assert from 'assert/strict';

import * as Lantern from '../../../lib/lantern/lantern.js';
import * as Lantern from './lantern.js';

const {BaseNode, NetworkNode} = Lantern;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import assert from 'assert/strict';

import * as Lantern from '../../../lib/lantern/lantern.js';
import * as Lantern from './lantern.js';

const {PageDependencyGraph, NetworkRequestTypes} = Lantern;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import * as Lantern from '../../../lib/lantern/lantern.js';
import * as Lantern from './lantern.js';

const {calculateSumOfBlockingTime} = Lantern.TBTUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import assert from 'assert/strict';

import * as Lantern from '../../../../lib/lantern/lantern.js';
import {readJson} from '../../../test-utils.js';
import * as Lantern from '../lantern.js';
import {readJson} from '../../../test/test-utils.js';
import {getComputationDataFromFixture} from './MetricTestUtils.js';

const {FirstContentfulPaint} = Lantern.Metrics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import assert from 'assert/strict';

import * as Lantern from '../../../../lib/lantern/lantern.js';
import * as Lantern from '../lantern.js';
import {getComputationDataFromFixture} from './MetricTestUtils.js';
import {readJson} from '../../../test-utils.js';
import {readJson} from '../../../test/test-utils.js';

const {Interactive, FirstContentfulPaint, LargestContentfulPaint} = Lantern.Metrics;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import assert from 'assert/strict';

import * as Lantern from '../../../../lib/lantern/lantern.js';
import * as Lantern from '../lantern.js';
import {getComputationDataFromFixture} from './MetricTestUtils.js';
import {readJson} from '../../../test-utils.js';
import {readJson} from '../../../test/test-utils.js';

const {FirstContentfulPaint, LargestContentfulPaint} = Lantern.Metrics;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import * as TraceEngine from '@paulirish/trace_engine';

import * as Lantern from '../../../../lib/lantern/lantern.js';
import {polyfillDOMRect} from '../../../../lib/polyfill-dom-rect.js';
import * as Lantern from '../lantern.js';
import {polyfillDOMRect} from '../../polyfill-dom-rect.js';

polyfillDOMRect();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

import * as Lantern from '../../../../lib/lantern/lantern.js';
import {readJson} from '../../../test-utils.js';
import * as Lantern from '../lantern.js';
import {readJson} from '../../../test/test-utils.js';
import {getComputationDataFromFixture} from './MetricTestUtils.js';

const {SpeedIndex, FirstContentfulPaint} = Lantern.Metrics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import assert from 'assert/strict';
import {URL} from 'url';

import * as Lantern from '../../../../lib/lantern/lantern.js';
import * as Lantern from '../lantern.js';

const {ConnectionPool} = Lantern.Simulation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import * as Lantern from '../../../../lib/lantern/lantern.js';
import * as Lantern from '../lantern.js';

const {DNSCache} = Lantern.Simulation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import assert from 'assert/strict';

import * as Lantern from '../../../../lib/lantern/lantern.js';
import {readJson} from '../../../test-utils.js';
import * as Lantern from '../lantern.js';
import {readJson} from '../../../test/test-utils.js';
import {runTraceEngine} from '../metrics/MetricTestUtils.js';

const {NetworkAnalyzer} = Lantern.Simulation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import assert from 'assert/strict';

import * as Lantern from '../../../../lib/lantern/lantern.js';
import {readJson} from '../../../test-utils.js';
import {runTraceEngine} from '../metrics/MetricTestUtils.js';
import * as Lantern from '../lantern.js';
import {readJson} from '../../../test/test-utils.js';
import {runTraceEngine} from '../../../test/lib/lantern/metrics/MetricTestUtils.js';

const {NetworkNode, CPUNode} = Lantern;
const {Simulator, DNSCache} = Lantern.Simulation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import assert from 'assert/strict';

import * as Lantern from '../../../../lib/lantern/lantern.js';
import * as Lantern from '../lantern.js';

const {TcpConnection} = Lantern.Simulation;

Expand Down
1 change: 1 addition & 0 deletions core/scripts/i18n/collect-strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const ignoredPathComponents = [
'**/core/lib/stack-packs.js',
'**/test/**',
'**/*-test.js',
'**/*.test.js',
'**/*-renderer.js',
'**/util-commonjs.js',
'treemap/app/src/main.js',
Expand Down
1 change: 1 addition & 0 deletions core/test/scripts/run-mocha-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ const defaultTestMatches = [
'cli/**/*-test.js',
'core/**/*-test.js',
'core/test/**/*-test-pptr.js',
'core/lib/lantern/*.test.js',
'report/**/*-test.js',
'shared/**/*-test.js',
'third-party/**/*-test.js',
Expand Down
18 changes: 10 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@
"core/test/lib/emulation-test.js",
"core/test/lib/i18n/i18n-test.js",
"core/test/lib/icons-test.js",
"core/test/lib/lantern/base-node-test.js",
"core/test/lib/lantern/metrics/*",
"core/test/lib/lantern/page-dependency-graph-test.js",
"core/test/lib/lantern/simulation/connection-pool-test.js",
"core/test/lib/lantern/simulation/dns-cache-test.js",
"core/test/lib/lantern/simulation/network-analyzer-test.js",
"core/test/lib/lantern/simulation/simulator-test.js",
// TODO(15841): remove when importing Lantern from npm
"core/lib/lantern/BaseNode.test.js",
"core/lib/lantern/metrics/*.test.js",
"core/lib/lantern/PageDependencyGraph.test.js",
"core/lib/lantern/simulation/ConnectionPool.test.js",
"core/lib/lantern/simulation/DNSCache.test.js",
"core/lib/lantern/simulation/NetworkAnalyzer.test.js",
"core/lib/lantern/simulation/Simulator.test.js",
// ------ done TODO
"core/test/lib/lh-element-test.js",
"core/test/lib/lighthouse-compatibility-test.js",
"core/test/lib/manifest-parser-test.js",
Expand Down Expand Up @@ -109,6 +111,6 @@
"core/test/computed/metrics/interactive-test.js",
"core/test/computed/tbt-impact-tasks-test.js",
"core/test/fixtures/config-plugins/lighthouse-plugin-simple/plugin-simple.js",
"core/test/lib/lantern/metrics/MetricTestUtils.js",
"core/lib/lantern/metrics/MetricTestUtils.js",
],
}

0 comments on commit 6859c5f

Please sign in to comment.