veza/apps/web/playwright.config.storybook.ts

60 lines
1.4 KiB
TypeScript
Raw Normal View History

import { defineConfig, devices } from '@playwright/test';
/**
* Playwright config for testing the full Storybook (all stories).
*
* Prerequisite: build Storybook first:
* npm run build-storybook
*
* Then run:
* npm run test:storybook:playwright
*
* The config starts a static server for storybook-static on port 6007
* (reuse existing if already running). Tests load each story iframe and
* assert no console errors / page crashes.
*/
const STORYBOOK_PORT = 6007;
const STORYBOOK_BASE = `http://localhost:${STORYBOOK_PORT}`;
export default defineConfig({
testDir: './e2e/tests/storybook',
testMatch: /.*\.spec\.ts/,
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
workers: process.env.CI ? 2 : 4,
timeout: 25000,
outputDir: 'e2e/test-results-storybook',
reporter: [
['html', { outputFolder: 'e2e/playwright-report-storybook', open: 'never' }],
['list'],
],
use: {
baseURL: STORYBOOK_BASE,
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'off',
viewport: { width: 1280, height: 720 },
},
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
viewport: { width: 1280, height: 720 },
},
},
],
webServer: {
command: 'node scripts/serve-storybook-static.cjs',
url: `${STORYBOOK_BASE}/index.json`,
reuseExistingServer: true,
timeout: 60_000,
cwd: process.cwd(),
},
});