- Extract common logging code to tests/e2e/utils/ - fixtures.ts: Playwright fixture with automatic log capture - test-utils.ts: Logging utilities and helper functions - Each test now automatically captures: - Console logs with timestamps and log levels - Page errors with full stack traces - Log files written per test to tests/logs/ - <test-name>.log for all console output - <test-name>.errors.log only when errors occur - Update all 13 spec files to use shared fixtures - Update README with test structure and logging docs - Net reduction of ~700 lines by removing duplicated code 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
23 lines
725 B
TypeScript
23 lines
725 B
TypeScript
import { test as base } from '@playwright/test';
|
|
import { setupTestLogger, writeTestLogs, TestLogger, MAIN_CANVAS, waitForApp, tryLoadApp, getCanvasBox } from './test-utils';
|
|
|
|
// Extend base test with automatic logging
|
|
export const test = base.extend<{
|
|
testLogger: TestLogger;
|
|
}>({
|
|
testLogger: async ({ page }, use, testInfo) => {
|
|
// Build test name from describe block + test title
|
|
const testName = testInfo.titlePath.join(' - ');
|
|
|
|
const logger = setupTestLogger(page);
|
|
|
|
await use(logger);
|
|
|
|
// Write logs after test completes
|
|
writeTestLogs(testName, logger);
|
|
logger.cleanup();
|
|
},
|
|
});
|
|
|
|
export { expect } from '@playwright/test';
|
|
export { MAIN_CANVAS, waitForApp, tryLoadApp, getCanvasBox };
|