Files
bakery-ia/frontend/playwright.config.ts
2025-11-14 07:46:29 +01:00

111 lines
2.5 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test';
/**
* Playwright configuration for Bakery-IA E2E tests
* See https://playwright.dev/docs/test-configuration
*/
export default defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use */
reporter: [
['html', { outputFolder: 'playwright-report' }],
['json', { outputFile: 'test-results/results.json' }],
['list'],
],
/* Shared settings for all the projects below */
use: {
/* Base URL to use in actions like `await page.goto('/')` */
baseURL: process.env.PLAYWRIGHT_BASE_URL || 'http://localhost:5173',
/* Collect trace when retrying the failed test */
trace: 'on-first-retry',
/* Take screenshot on failure */
screenshot: 'only-on-failure',
/* Record video on failure */
video: 'retain-on-failure',
/* Maximum time each action (click, fill, etc) can take */
actionTimeout: 10000,
},
/* Configure projects for major browsers */
projects: [
// Setup project to authenticate once
{
name: 'setup',
testMatch: /.*\.setup\.ts/,
},
// Desktop browsers
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
storageState: 'tests/.auth/user.json',
},
dependencies: ['setup'],
},
{
name: 'firefox',
use: {
...devices['Desktop Firefox'],
storageState: 'tests/.auth/user.json',
},
dependencies: ['setup'],
},
{
name: 'webkit',
use: {
...devices['Desktop Safari'],
storageState: 'tests/.auth/user.json',
},
dependencies: ['setup'],
},
// Mobile viewports
{
name: 'Mobile Chrome',
use: {
...devices['Pixel 5'],
storageState: 'tests/.auth/user.json',
},
dependencies: ['setup'],
},
{
name: 'Mobile Safari',
use: {
...devices['iPhone 13'],
storageState: 'tests/.auth/user.json',
},
dependencies: ['setup'],
},
],
/* Run your local dev server before starting the tests */
webServer: {
command: 'npm run dev',
url: 'http://localhost:5173',
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
},
});