5
5
*/
6
6
'use strict' ;
7
7
8
- const assert = require ( 'assert' ) . strict ;
9
- const lhBackground = require ( '../lightrider/lightrider-entry.js' ) ;
10
- const Runner = require ( '../../lighthouse-core/runner.js' ) ;
11
- const LHError = require ( '../../lighthouse-core/lib/lh-error.js' ) ;
8
+ import { jest } from '@jest/globals' ;
9
+ import { strict as assert } from 'assert' ;
10
+ import { runLighthouseInLR } from '../../lightrider/lightrider-entry.js' ;
11
+ import Runner from '../../../lighthouse-core/runner.js' ;
12
+ import LHError from '../../../lighthouse-core/lib/lh-error.js' ;
12
13
13
14
/* eslint-env jest */
14
15
@@ -31,7 +32,7 @@ describe('lightrider-entry', () => {
31
32
const url = 'https://example.com' ;
32
33
const output = 'json' ;
33
34
34
- const result = await lhBackground . runLighthouseInLR ( mockConnection , url , { output} , { } ) ;
35
+ const result = await runLighthouseInLR ( mockConnection , url , { output} , { } ) ;
35
36
const parsedResult = JSON . parse ( result ) ;
36
37
assert . strictEqual ( parsedResult . runtimeError . code , connectionError . code ) ;
37
38
assert . ok ( parsedResult . runtimeError . message . includes ( connectionError . friendlyMessage ) ) ;
@@ -52,7 +53,7 @@ describe('lightrider-entry', () => {
52
53
const url = 'https://example.com' ;
53
54
const output = 'json' ;
54
55
55
- const result = await lhBackground . runLighthouseInLR ( mockConnection , url , { output} , { } ) ;
56
+ const result = await runLighthouseInLR ( mockConnection , url , { output} , { } ) ;
56
57
const parsedResult = JSON . parse ( result ) ;
57
58
assert . strictEqual ( parsedResult . runtimeError . code , LHError . UNKNOWN_ERROR ) ;
58
59
assert . ok ( parsedResult . runtimeError . message . includes ( errorMsg ) ) ;
@@ -64,7 +65,7 @@ describe('lightrider-entry', () => {
64
65
const mockConnection = { } ;
65
66
const url = 'https://example.com' ;
66
67
67
- await lhBackground . runLighthouseInLR ( mockConnection , url , { } , { } ) ;
68
+ await runLighthouseInLR ( mockConnection , url , { } , { } ) ;
68
69
const config = runStub . mock . calls [ 0 ] [ 1 ] . config ;
69
70
assert . equal ( config . settings . channel , 'lr' ) ;
70
71
@@ -78,7 +79,7 @@ describe('lightrider-entry', () => {
78
79
const url = 'https://example.com' ;
79
80
80
81
const lrDevice = 'desktop' ;
81
- await lhBackground . runLighthouseInLR ( mockConnection , url , { } , { lrDevice} ) ;
82
+ await runLighthouseInLR ( mockConnection , url , { } , { lrDevice} ) ;
82
83
const config = runStub . mock . calls [ 0 ] [ 1 ] . config ;
83
84
assert . equal ( config . settings . formFactor , 'desktop' ) ;
84
85
@@ -92,7 +93,7 @@ describe('lightrider-entry', () => {
92
93
const url = 'https://example.com' ;
93
94
94
95
const lrDevice = 'mobile' ;
95
- await lhBackground . runLighthouseInLR ( mockConnection , url , { } , { lrDevice} ) ;
96
+ await runLighthouseInLR ( mockConnection , url , { } , { lrDevice} ) ;
96
97
const config = runStub . mock . calls [ 0 ] [ 1 ] . config ;
97
98
assert . equal ( config . settings . formFactor , 'mobile' ) ;
98
99
@@ -111,7 +112,7 @@ describe('lightrider-entry', () => {
111
112
onlyAudits : [ 'network-requests' ] ,
112
113
} ,
113
114
} ;
114
- await lhBackground . runLighthouseInLR ( mockConnection , url , { } , { configOverride} ) ;
115
+ await runLighthouseInLR ( mockConnection , url , { } , { configOverride} ) ;
115
116
const config = runStub . mock . calls [ 0 ] [ 1 ] . config ;
116
117
assert . equal ( config . settings . onlyAudits . length , 1 ) ;
117
118
assert . equal ( config . settings . onlyAudits [ 0 ] , 'network-requests' ) ;
@@ -141,7 +142,7 @@ describe('lightrider-entry', () => {
141
142
const lrFlags = {
142
143
logAssets : true ,
143
144
} ;
144
- const resultJson = await lhBackground . runLighthouseInLR ( mockConnection , url , { } , lrFlags ) ;
145
+ const resultJson = await runLighthouseInLR ( mockConnection , url , { } , lrFlags ) ;
145
146
const result = JSON . parse ( resultJson ) ;
146
147
expect ( result . artifacts ) . toMatchObject ( {
147
148
Artifact : {
0 commit comments