- npm run test:kicad now auto-runs setup script first - Create separate playwright-kicad.config.ts for KiCad tests - Fix kicad spec to use web server instead of file:// paths - Remove duplicate pcbnew.html/wasm from tests/kicad/ (proper files are in tests/apps/kicad/) Test separation: - npm test: runs only wxWidgets tests (tests/e2e/) - npm run test:kicad: runs only KiCad tests (tests/kicad/) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
68 lines
1.6 KiB
TypeScript
68 lines
1.6 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
import { execSync } from 'child_process';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
const PORT_FILE = path.join(__dirname, '.test-port');
|
|
|
|
// Get existing port from file or find a new one
|
|
function getOrFindPort(): number {
|
|
try {
|
|
const stat = fs.statSync(PORT_FILE);
|
|
const age = Date.now() - stat.mtimeMs;
|
|
if (age < 60000) {
|
|
const port = parseInt(fs.readFileSync(PORT_FILE, 'utf-8').trim());
|
|
if (port > 0 && port < 65536) {
|
|
return port;
|
|
}
|
|
}
|
|
} catch {
|
|
// File doesn't exist or can't be read
|
|
}
|
|
|
|
const port = findFreePort();
|
|
fs.writeFileSync(PORT_FILE, port.toString());
|
|
return port;
|
|
}
|
|
|
|
function findFreePort(): number {
|
|
try {
|
|
const result = execSync(
|
|
'python3 -c "import socket; s=socket.socket(); s.bind((\'\',0)); print(s.getsockname()[1]); s.close()"',
|
|
{ encoding: 'utf-8' }
|
|
);
|
|
return parseInt(result.trim());
|
|
} catch {
|
|
return 9000 + Math.floor(Math.random() * 1000);
|
|
}
|
|
}
|
|
|
|
const port = getOrFindPort();
|
|
|
|
export default defineConfig({
|
|
testDir: './kicad',
|
|
fullyParallel: true,
|
|
forbidOnly: !!process.env.CI,
|
|
retries: process.env.CI ? 2 : 0,
|
|
workers: process.env.CI ? 1 : undefined,
|
|
reporter: 'html',
|
|
timeout: 120000, // KiCad WASM needs more time to load
|
|
|
|
use: {
|
|
baseURL: `http://localhost:${port}`,
|
|
trace: 'on-first-retry',
|
|
},
|
|
|
|
projects: [
|
|
{
|
|
name: 'chromium',
|
|
use: { ...devices['Desktop Chrome'] },
|
|
},
|
|
],
|
|
|
|
webServer: {
|
|
command: `npx serve apps -p ${port} -c ../serve.json`,
|
|
port: port,
|
|
reuseExistingServer: !process.env.CI,
|
|
},
|
|
});
|