Fix: correct Playwright Docker tag, sequential Lighthouse audits, devtools throttling
- Pin playwright npm to 1.59.1 to match Docker image tag - Update base image to mcr.microsoft.com/playwright:v1.59.1-jammy - Run Lighthouse desktop and mobile sequentially (parallel caused port conflict) - Switch to devtools throttling (simulate caused LanternError on localhost) - Skip browser download during npm ci (image has browsers pre-installed) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
FROM mcr.microsoft.com/playwright/node:20-noble
|
||||
FROM mcr.microsoft.com/playwright:v1.59.1-jammy
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Install dependencies first (layer cache)
|
||||
COPY package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
RUN PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm ci --omit=dev
|
||||
|
||||
# Copy source
|
||||
COPY src/ ./src/
|
||||
|
||||
2231
package-lock.json
generated
Normal file
2231
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@
|
||||
"dependencies": {
|
||||
"chrome-launcher": "^1.1.2",
|
||||
"lighthouse": "^12.2.1",
|
||||
"playwright": "^1.44.0"
|
||||
"playwright": "1.59.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
|
||||
@@ -39,7 +39,6 @@ async function main() {
|
||||
|
||||
// Stage 2 & 3: Lighthouse desktop + mobile
|
||||
console.log('Running Lighthouse desktop audit...');
|
||||
console.log('Running Lighthouse mobile audit...');
|
||||
const lighthouseResults = await runLighthouse(url, rawDir);
|
||||
|
||||
// Stage 4: Report assembly
|
||||
|
||||
@@ -65,7 +65,7 @@ async function runPreset(url, preset, rawDir) {
|
||||
const chromePath = chromium.executablePath();
|
||||
const chrome = await launch({
|
||||
chromePath,
|
||||
chromeFlags: ['--headless=new', '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage'],
|
||||
chromeFlags: ['--headless', '--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage'],
|
||||
});
|
||||
|
||||
try {
|
||||
@@ -82,7 +82,7 @@ async function runPreset(url, preset, rawDir) {
|
||||
deviceScaleFactor: isDesktop ? 1 : 2,
|
||||
disabled: false,
|
||||
},
|
||||
throttlingMethod: 'simulate',
|
||||
throttlingMethod: 'devtools',
|
||||
onlyCategories: ['performance', 'accessibility', 'best-practices', 'seo'],
|
||||
};
|
||||
|
||||
@@ -116,10 +116,9 @@ async function runPreset(url, preset, rawDir) {
|
||||
}
|
||||
|
||||
export async function runLighthouse(url, rawDir) {
|
||||
const [desktop, mobile] = await Promise.all([
|
||||
runPreset(url, 'desktop', rawDir),
|
||||
runPreset(url, 'mobile', rawDir),
|
||||
]);
|
||||
const desktop = await runPreset(url, 'desktop', rawDir);
|
||||
console.log('Running Lighthouse mobile audit...');
|
||||
const mobile = await runPreset(url, 'mobile', rawDir);
|
||||
return [desktop, mobile];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user