Use Firefox for KiCad headless tests on ARM Mac

Chrome headless crashes on ARM Mac due to a known Chromium bug where
SwiftShader WebGL is disabled on ARM architecture (issues #1416283,
#338414704). Firefox headless works reliably using native Metal.

Changes:
- Use Firefox as default for npm run test:kicad (headless)
- Use Chrome with --headed flag for npm run test:kicad:headed
- Add viewport size and increase timeout for KiCad WASM
- Simplify pcbnew.spec.ts test assertions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Viktor Vaczi 2025-12-29 10:51:03 +01:00
commit 9ccb07ad81
3 changed files with 27 additions and 9 deletions

View file

@ -17,12 +17,13 @@ test.describe('PCBnew WASM', () => {
await page.goto('/kicad/pcbnew.html');
});
test('should load PCBnew WASM module', async ({ page, testLogger }) => {
// Wait for WASM to initialize (look for canvas or status indicator)
// This is a basic smoke test - expand as PCBnew integration matures
await expect(page.locator('canvas')).toBeVisible({ timeout: 60000 });
test('should load PCBnew WASM module', async ({ page }) => {
// Wait for main canvas to be visible (KiCad takes time to initialize)
await expect(page.locator('#canvas')).toBeVisible({ timeout: 90000 });
// testLogger automatically captures all console output and errors
// Verify multiple canvases are created (11 for setup wizard)
const canvasCount = await page.locator('canvas').count();
expect(canvasCount).toBeGreaterThan(0);
});
test.skip('should render without JavaScript errors', async ({ page, testLogger }) => {

View file

@ -9,8 +9,8 @@
"build-wasm": "cd apps && make -f Makefile.wasm",
"serve": "npx serve apps -p 8080 -c ../serve.json",
"setup:kicad": "./scripts/setup-kicad-wasm.sh",
"test:kicad": "npm run setup:kicad && playwright test --config=playwright-kicad.config.ts",
"test:kicad:headed": "npm run setup:kicad && playwright test --config=playwright-kicad.config.ts --headed"
"test:kicad": "npm run setup:kicad && playwright test --config=playwright-kicad.config.ts --project=firefox",
"test:kicad:headed": "npm run setup:kicad && playwright test --config=playwright-kicad.config.ts --project=chromium --headed"
},
"devDependencies": {
"@playwright/test": "^1.40.0",

View file

@ -5,6 +5,10 @@ import * as path from 'path';
const PORT_FILE = path.join(__dirname, '.test-port');
// NOTE: Chrome headless crashes on ARM Mac due to SwiftShader WebGL bug
// (Chromium issues #1416283, #338414704). Firefox headless works reliably.
// Use --project=firefox for headless, --project=chromium for headed debugging.
// Get existing port from file or find a new one
function getOrFindPort(): number {
try {
@ -47,7 +51,7 @@ export default defineConfig({
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: 'html',
timeout: 120000, // KiCad WASM needs more time to load
timeout: 180000, // KiCad WASM needs more time to load (3 minutes)
use: {
baseURL: `http://localhost:${port}`,
@ -56,8 +60,21 @@ export default defineConfig({
projects: [
{
// Firefox is the default for headless testing (works on ARM Mac)
name: 'firefox',
use: {
...devices['Desktop Firefox'],
viewport: { width: 1280, height: 720 },
},
},
{
// Chrome for headed debugging only (headless crashes on ARM Mac)
// Use --headed flag when running: npm run test:kicad:headed
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
use: {
...devices['Desktop Chrome'],
viewport: { width: 1280, height: 720 },
},
},
],