Add Playwright E2E tests with MSW API mocking
- Playwright + @msw/playwright + @msw/source for OpenAPI-driven mocks - Chromium-only configuration with Vite dev server integration - Smoke tests: home page, CTA, navigation - US-1 tests: validation, event creation flow, localStorage, error handling - Suppress Node 25 --localstorage-file warning from MSW cookieStore
This commit is contained in:
41
frontend/playwright.config.ts
Normal file
41
frontend/playwright.config.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { defineConfig, devices } from '@playwright/test'
|
||||
|
||||
// Suppress Node 25 warning from MSW's cookieStore accessing native localStorage
|
||||
// without --localstorage-file being set. Harmless — MSW doesn't need file-backed storage.
|
||||
const originalEmit = process.emit.bind(process)
|
||||
process.emit = function (event: string, ...args: unknown[]) {
|
||||
if (event === 'warning' && args[0] instanceof Error && args[0].message.includes('--localstorage-file')) {
|
||||
return false
|
||||
}
|
||||
return originalEmit(event, ...args)
|
||||
} as typeof process.emit
|
||||
|
||||
export default defineConfig({
|
||||
testDir: './e2e',
|
||||
fullyParallel: true,
|
||||
forbidOnly: !!process.env.CI,
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
reporter: process.env.CI ? 'github' : 'html',
|
||||
|
||||
use: {
|
||||
baseURL: 'http://localhost:5173',
|
||||
trace: 'on-first-retry',
|
||||
screenshot: 'only-on-failure',
|
||||
},
|
||||
|
||||
projects: [
|
||||
{
|
||||
name: 'chromium',
|
||||
use: { ...devices['Desktop Chrome'] },
|
||||
},
|
||||
],
|
||||
|
||||
webServer: {
|
||||
command: 'npm run dev',
|
||||
url: 'http://localhost:5173',
|
||||
reuseExistingServer: !process.env.CI,
|
||||
timeout: 120_000,
|
||||
stdout: 'pipe',
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user