48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
|
|
/**
|
|
* Playwright configuration.
|
|
*
|
|
* Tests run against the Vite dev server with the mock API enabled, so they
|
|
* don't require Django to be running. Each test gets an isolated user session
|
|
* via the `storageState` reset in globalSetup (implicit: every test starts
|
|
* with a blank context).
|
|
*
|
|
* Run:
|
|
* npx playwright install chromium # first time only — installs browsers
|
|
* npm run test:e2e # headless
|
|
* npm run test:e2e:headed # opens a browser
|
|
* npm run test:e2e:ui # Playwright UI mode
|
|
*/
|
|
export default defineConfig({
|
|
testDir: './tests/e2e',
|
|
timeout: 30_000,
|
|
expect: { timeout: 5_000 },
|
|
fullyParallel: false, // the mock plugin writes to shared JSON files on disk
|
|
workers: 1,
|
|
forbidOnly: !!process.env.CI,
|
|
retries: process.env.CI ? 1 : 0,
|
|
reporter: [['list'], ['html', { open: 'never' }]],
|
|
use: {
|
|
baseURL: 'http://127.0.0.1:5173',
|
|
trace: 'retain-on-failure',
|
|
video: 'retain-on-failure',
|
|
screenshot: 'only-on-failure',
|
|
},
|
|
projects: [
|
|
{
|
|
name: 'chromium',
|
|
use: { ...devices['Desktop Chrome'] },
|
|
},
|
|
],
|
|
webServer: {
|
|
command: 'npm run dev -- --port 5173 --strictPort',
|
|
url: 'http://127.0.0.1:5173',
|
|
reuseExistingServer: !process.env.CI,
|
|
timeout: 60_000,
|
|
env: {
|
|
VITE_USE_MOCK_API: 'true',
|
|
VITE_API_BASE_URL: '/api',
|
|
},
|
|
},
|
|
});
|