diff --git a/package.json b/package.json index 9be264d..1157931 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "test:unit:watch": "vitest", "test:coverage": "vitest run --coverage", "test:e2e": "playwright test", - "test:e2e:docker": "BASE_URL=http://localhost:3000 playwright test tests/docker-deployment.spec.ts" + "test:e2e:docker": "BASE_URL=http://localhost:3000 playwright test --config=playwright.docker.config.ts" }, "devDependencies": { "@playwright/test": "^1.58.1", diff --git a/playwright.config.ts b/playwright.config.ts index 561e7fd..44524df 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,20 +1,31 @@ -import { defineConfig } from '@playwright/test'; +import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ - testDir: './tests', - fullyParallel: true, + testDir: './tests/e2e', + fullyParallel: false, // Shared database - avoid race conditions forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 0, - workers: process.env.CI ? 1 : undefined, - reporter: 'html', + workers: 1, // Single worker for database safety + reporter: [['html', { open: 'never' }], ['github']], use: { - baseURL: process.env.BASE_URL || 'http://localhost:3000', - trace: 'on-first-retry' + baseURL: process.env.BASE_URL || 'http://localhost:4173', + trace: 'on-first-retry', + screenshot: 'only-on-failure', + video: 'off' }, projects: [ { - name: 'chromium', - use: { browserName: 'chromium' } + name: 'chromium-desktop', + use: { ...devices['Desktop Chrome'] } + }, + { + name: 'chromium-mobile', + use: { ...devices['Pixel 5'] } } - ] + ], + webServer: { + command: 'npm run build && npm run preview', + port: 4173, + reuseExistingServer: !process.env.CI + } }); diff --git a/playwright.docker.config.ts b/playwright.docker.config.ts new file mode 100644 index 0000000..d5db9fd --- /dev/null +++ b/playwright.docker.config.ts @@ -0,0 +1,25 @@ +import { defineConfig, devices } from '@playwright/test'; + +/** + * Playwright config for Docker deployment tests + * These tests run against the Docker container, not the dev server + */ +export default defineConfig({ + testDir: './tests', + testMatch: 'docker-deployment.spec.ts', + fullyParallel: true, + forbidOnly: !!process.env.CI, + retries: process.env.CI ? 2 : 0, + workers: process.env.CI ? 1 : undefined, + reporter: 'html', + use: { + baseURL: process.env.BASE_URL || 'http://localhost:3000', + trace: 'on-first-retry' + }, + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] } + } + ] +});