- Fix unused parameter warning in global-setup.ts - Fix unknown error type in error handling - Fix unused variable in test-runner.ts All tests now compile without TypeScript errors. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { chromium, FullConfig } from '@playwright/test';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
|
|
async function globalSetup(_config: FullConfig) {
|
|
// Ensure screenshots directory exists
|
|
const screenshotsDir = path.join(process.cwd(), 'screenshots');
|
|
if (!fs.existsSync(screenshotsDir)) {
|
|
fs.mkdirSync(screenshotsDir, { recursive: true });
|
|
}
|
|
|
|
// Clear previous screenshots
|
|
const files = fs.readdirSync(screenshotsDir);
|
|
for (const file of files) {
|
|
if (file.endsWith('.png')) {
|
|
fs.unlinkSync(path.join(screenshotsDir, file));
|
|
}
|
|
}
|
|
|
|
// Optional: Pre-warm the application by visiting it once
|
|
const browser = await chromium.launch();
|
|
const context = await browser.newContext();
|
|
const page = await context.newPage();
|
|
|
|
try {
|
|
await page.goto('http://localhost:5173', { waitUntil: 'networkidle' });
|
|
console.log('✅ Application pre-warmed successfully');
|
|
} catch (error) {
|
|
console.warn('⚠️ Could not pre-warm application:', (error as Error).message);
|
|
} finally {
|
|
await context.close();
|
|
await browser.close();
|
|
}
|
|
}
|
|
|
|
export default globalSetup; |