Skip to content

Commit 75fb12f

Browse files
committed
fix test mocks
1 parent 5dc24d0 commit 75fb12f

File tree

4 files changed

+7
-16
lines changed

4 files changed

+7
-16
lines changed

src/e2e/mocks/puppeteer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ const puppeteer = () =>
22
jest.unstable_mockModule('puppeteer', () => {
33
return {
44
default: {
5-
createBrowserFetcher: () => ({
6-
localRevisions: () => Promise.resolve(['123']),
7-
revisionInfo: () => Promise.resolve({ executablePath: 'path' }),
5+
launch: () => Promise.resolve({
6+
wsEndpoint: () => 'ws://127.0.0.1:9222/devtools/browser/xyz',
7+
close: () => Promise.resolve(),
88
}),
99
},
1010
};

src/lib/run-audit-with-server/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { join } from 'path';
22

33
import { formatResults } from '../../format.js';
4-
import { runLighthouse, getBrowserPath } from '../../run-lighthouse.js';
4+
import { runLighthouse } from '../../run-lighthouse.js';
55
import persistResults from '../persist-results/index.js';
66
import getServer from '../get-server/index.js';
77

@@ -16,13 +16,11 @@ const runAuditWithServer = async ({
1616
try {
1717
const { server } = getServer({ serveDir: serveDir, auditUrl: url });
1818

19-
const browserPath = await getBrowserPath();
20-
2119
const { error, results } = await new Promise((resolve) => {
2220
const instance = server.listen(async () => {
2321
try {
2422
const fullPath = path ? `${server.url}/${path}` : server.url;
25-
const results = await runLighthouse(browserPath, fullPath, settings);
23+
const results = await runLighthouse(fullPath, settings);
2624
resolve({ error: false, results });
2725
} catch (error) {
2826
resolve({ error });

src/lib/run-event/index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ const runEvent = async ({
1717
} = {}) => {
1818
const isOnSuccess = event === 'onSuccess';
1919

20-
const deployUrl =
21-
'https://68244ec43a5a6b46e855abe0--testing-secret-scanning-ui.netlify.app/';
20+
const deployUrl = process.env.DEPLOY_URL;
2221

2322
// If we don't have the deploy URL to test against, we can't run Lighthouse onSuccess.
2423
// If running locally, ensure you have a DEPLOY_URL set in your .env file
@@ -68,7 +67,6 @@ const runEvent = async ({
6867
});
6968

7069
console.log(startMessage);
71-
console.log('*** url', url);
7270

7371
const runner = isOnSuccess ? runAuditWithUrl : runAuditWithServer;
7472
const { errors, summary, shortSummary, details, report, runtimeError } =

src/run-lighthouse.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@ import puppeteer from 'puppeteer';
22
import lighthouse from 'lighthouse';
33
import log from 'lighthouse-logger';
44

5-
export const getBrowserPath = async () => {
6-
// In newer Puppeteer versions, we can get the executable path directly
7-
return puppeteer.executablePath();
8-
};
95

10-
export const runLighthouse = async (browserPath, url, settings) => {
6+
export const runLighthouse = async (url, settings) => {
117
let chrome;
128
try {
139
const logLevel = 'error';
1410
log.setLevel(logLevel);
1511
chrome = await puppeteer.launch({
16-
executablePath: browserPath,
1712
args: [
1813
'--headless',
1914
'--no-sandbox',

0 commit comments

Comments
 (0)