LibreChat/e2e/playwright.config.lighthouse.ts
Danny Avila 445668a371
🧭 ci: Assert Lighthouse Blocking Time at a Reference CPU on the Quietest Run (#18406)
Total blocking time is CPU time, and the hosted runner's CPU is not a constant: Lighthouse's
own benchmark of the runner moves by more than 2x between consecutive runs of one build on a
two-core runner, and blocking time moves with it. A median of three raw measurements against
a fixed budget therefore fails on the runner rather than on the page.

Rescale each run's main-thread tasks by that run's benchmark index to a reference CPU, assert
the lowest run instead of the median, and measure an over-budget batch once more before
failing. Budgets move to their own file so a fork with a heavier client changes numbers only.
2026-11-18 07:47:01 -05:00

41 lines
1.4 KiB
TypeScript

import path from 'node:path';
import { defineConfig } from '@playwright/test';
import mockConfig from './playwright.config.mock';
const latencyHook = path.resolve(__dirname, 'benchmarks/mongoose-latency-hook.cjs');
const regressionHook = path.resolve(__dirname, 'lighthouse/regression.cjs');
const servers = (Array.isArray(mockConfig.webServer) ? mockConfig.webServer : []).filter((server) =>
server.command.endsWith('start-server.js'),
);
if (servers.length !== 1) {
throw new Error('Lighthouse requires the isolated single-server harness (E2E_REPLICAS=1).');
}
export default defineConfig({
...mockConfig,
testDir: 'lighthouse',
outputDir: 'lighthouse/.test-results',
// Covers the confirming batch an over-budget audit measures before it fails.
timeout: 600_000,
retries: 0,
reporter: [['line']],
webServer: servers.map((server) => ({
...server,
env: {
...server.env,
CONFIG_PATH: path.resolve(__dirname, 'lighthouse/librechat.yaml'),
ENDPOINTS: 'openAI',
OPENAI_MODELS: 'gpt-4o-mini',
ASSISTANTS_API_KEY: '',
E2E_USE_MEMORY_MONGO: 'true',
E2E_LATENCY_MONGO_DELAY_MS: '250',
NODE_OPTIONS: [
server.env.NODE_OPTIONS,
`--require=${latencyHook}`,
...(process.env.LIGHTHOUSE_REGRESSION === 'serial-reads'
? [`--require=${regressionHook}`]
: []),
].join(' '),
},
})),
});