feat: add shared fixtures for testing

This commit is contained in:
张翔
2026-03-06 12:13:01 +08:00
parent b6084ec01a
commit e47171bf01
3 changed files with 109 additions and 0 deletions
@@ -0,0 +1,29 @@
import { test as base } from '@playwright/test';
import { PerformanceMonitor } from '../utils/performance/PerformanceMonitor';
import { LighthouseRunner } from '../utils/performance/LighthouseRunner';
import { CoreWebVitals } from '../utils/performance/CoreWebVitals';
type MyFixtures = {
performanceMonitor: PerformanceMonitor;
lighthouseRunner: LighthouseRunner;
coreWebVitals: CoreWebVitals;
};
export const test = base.extend<MyFixtures>({
performanceMonitor: async ({ page }, use) => {
const monitor = new PerformanceMonitor(page);
await use(monitor);
},
lighthouseRunner: async ({ page }, use) => {
const runner = new LighthouseRunner(page);
await use(runner);
},
coreWebVitals: async ({ page }, use) => {
const vitals = new CoreWebVitals(page);
await use(vitals);
}
});
export { expect } from '@playwright/test';