58 lines
2.2 KiB
TypeScript
58 lines
2.2 KiB
TypeScript
import { defineConfig } from '@playwright/test'
|
|
import path from 'node:path'
|
|
|
|
const projectName = process.env.DODO_E2E_PROJECT
|
|
if (!projectName) throw new Error('DODO_E2E_PROJECT is required; use pnpm test:e2e:mobile')
|
|
const project = projectName === 'mobile-390'
|
|
? { name: 'mobile-390', use: { viewport: { width: 390, height: 844 }, deviceScaleFactor: 3, isMobile: true, hasTouch: true } }
|
|
: projectName === 'mobile-375'
|
|
? { name: 'mobile-375', testIgnore: /backup-roundtrip\.spec\.ts/, use: { viewport: { width: 375, height: 667 }, deviceScaleFactor: 2, isMobile: true, hasTouch: true } }
|
|
: projectName === 'desktop-1440'
|
|
? { name: 'desktop-1440', use: { viewport: { width: 1440, height: 900 } } }
|
|
: projectName === 'desktop-931'
|
|
? { name: 'desktop-931', use: { viewport: { width: 931, height: 900 } } }
|
|
: projectName === 'desktop-721'
|
|
? { name: 'desktop-721', use: { viewport: { width: 721, height: 900 } } }
|
|
: projectName === 'desktop-720'
|
|
? { name: 'desktop-720', use: { viewport: { width: 720, height: 900 } } }
|
|
: null
|
|
if (!project) throw new Error(`unknown DODO_E2E_PROJECT: ${projectName}`)
|
|
|
|
const runtimeRoot = path.resolve('playwright-runtime', projectName)
|
|
|
|
export default defineConfig({
|
|
testDir: './e2e',
|
|
fullyParallel: false,
|
|
workers: 1,
|
|
timeout: 45_000,
|
|
expect: {
|
|
timeout: 8_000,
|
|
toHaveScreenshot: {
|
|
animations: 'disabled',
|
|
caret: 'hide',
|
|
maxDiffPixelRatio: 0.001,
|
|
},
|
|
},
|
|
snapshotPathTemplate: '{testDir}/{testFilePath}-snapshots/{arg}-{projectName}{ext}',
|
|
outputDir: path.join(runtimeRoot, 'test-results'),
|
|
reporter: [['line'], ['html', { outputFolder: path.join(runtimeRoot, 'report'), open: 'never' }]],
|
|
globalSetup: './e2e/global-setup.ts',
|
|
use: {
|
|
baseURL: 'http://127.0.0.1:5173',
|
|
storageState: path.join(runtimeRoot, 'auth.json'),
|
|
reducedMotion: 'reduce',
|
|
trace: 'retain-on-failure',
|
|
screenshot: 'only-on-failure',
|
|
video: 'retain-on-failure',
|
|
},
|
|
projects: [project],
|
|
webServer: {
|
|
command: 'node scripts/playwright-mobile-server.mjs',
|
|
url: 'http://127.0.0.1:5173',
|
|
reuseExistingServer: false,
|
|
timeout: 120_000,
|
|
stdout: 'pipe',
|
|
stderr: 'pipe',
|
|
},
|
|
})
|