40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
|
|
const externalServer = process.env.PLAYWRIGHT_EXTERNAL_SERVER === 'true'
|
|
const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? 'http://127.0.0.1:5255'
|
|
const acceptanceDatabase = join(tmpdir(), `jiaowu-playwright-${process.pid}.sqlite`)
|
|
|
|
export default defineConfig({
|
|
testDir: './e2e',
|
|
timeout: 30_000,
|
|
expect: { timeout: 8_000 },
|
|
fullyParallel: false,
|
|
retries: process.env.CI ? 1 : 0,
|
|
reporter: process.env.CI
|
|
? [['line'], ['html', { outputFolder: 'playwright-report', open: 'never' }]]
|
|
: 'line',
|
|
use: {
|
|
baseURL,
|
|
locale: 'zh-CN',
|
|
trace: 'retain-on-failure',
|
|
screenshot: 'only-on-failure',
|
|
video: 'retain-on-failure',
|
|
},
|
|
projects: [
|
|
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
|
|
],
|
|
webServer: externalServer ? undefined : {
|
|
command: 'dotnet run --project ../src/Jiaowu.Api/Jiaowu.Api.csproj --configuration Release --no-build',
|
|
url: `${baseURL}/health/live`,
|
|
reuseExistingServer: true,
|
|
timeout: 120_000,
|
|
env: {
|
|
ASPNETCORE_ENVIRONMENT: 'Development',
|
|
ASPNETCORE_URLS: baseURL,
|
|
ConnectionStrings__SQLite: `Data Source=${acceptanceDatabase}`,
|
|
},
|
|
},
|
|
})
|