Skip to content

Commit 0f89e81

Browse files
committed
puppeteer upgrade, tests passing locally
1 parent e067064 commit 0f89e81

File tree

4 files changed

+353
-37
lines changed

4 files changed

+353
-37
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"express": "^4.17.1",
3131
"html-minifier": "^4.0.0",
3232
"lighthouse": "^9.6.3",
33-
"puppeteer": "^18.0.0"
33+
"puppeteer": "^24.8.2"
3434
},
3535
"engines": {
3636
"node": ">=18.14.0"

src/e2e/mocks/puppeteer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ const puppeteer = () =>
22
jest.unstable_mockModule('puppeteer', () => {
33
return {
44
default: {
5+
launch: () => {
6+
return { executablePath: () => 'path'}
7+
},
58
createBrowserFetcher: () => ({
69
localRevisions: () => Promise.resolve(['123']),
710
revisionInfo: () => Promise.resolve({ executablePath: 'path' }),

src/run-lighthouse.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import log from 'lighthouse-logger';
44
import chromeLauncher from 'chrome-launcher';
55

66
export const getBrowserPath = async () => {
7-
const browserFetcher = puppeteer.createBrowserFetcher();
8-
const revisions = await browserFetcher.localRevisions();
9-
if (revisions.length <= 0) {
10-
throw new Error('Could not find local browser');
11-
}
12-
const info = await browserFetcher.revisionInfo(revisions[0]);
13-
return info.executablePath;
7+
const browser = await puppeteer.launch({
8+
headless: "new",
9+
args: ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage']
10+
});
11+
const executablePath = browser.executablePath();
12+
return executablePath;
1413
};
1514

1615
export const runLighthouse = async (browserPath, url, settings) => {

0 commit comments

Comments
 (0)