CI / build (push) Successful in 4m58s
Co-Authored-By: Claude Opus 5.5 <[email protected]>
42 lines
1.6 KiB
TypeScript
42 lines
1.6 KiB
TypeScript
import { defineConfig, devices } from "@playwright/test";
|
|
import { E2E_PORT, e2eEnv } from "./tests/e2e/env";
|
|
|
|
export default defineConfig({
|
|
testDir: "./tests/e2e",
|
|
fullyParallel: true,
|
|
forbidOnly: !!process.env.CI,
|
|
retries: process.env.CI ? 2 : 0,
|
|
reporter: process.env.CI ? "github" : "list",
|
|
use: {
|
|
baseURL: `http://localhost:${E2E_PORT}`,
|
|
trace: "on-first-retry",
|
|
},
|
|
// 無法下載 Playwright 內建瀏覽器時,可設 PLAYWRIGHT_CHANNEL=chrome(或 msedge)改用本機已安裝的瀏覽器。
|
|
// 系統時間會影響全站:一般測試前先固定在本月 10 日(pin-clock,申請可送出期間為次月 1–20 日),
|
|
// 跑完清除;clock.spec 在其他測試都跑完後才單獨執行。
|
|
projects: [
|
|
{ name: "pin-clock", testMatch: /pin-clock\.setup\.ts$/, teardown: "unpin-clock" },
|
|
{ name: "unpin-clock", testMatch: /pin-clock\.teardown\.ts$/ },
|
|
{
|
|
name: "chromium",
|
|
testIgnore: /clock\.spec\.ts$/,
|
|
dependencies: ["pin-clock"],
|
|
use: { ...devices["Desktop Chrome"], channel: process.env.PLAYWRIGHT_CHANNEL || undefined },
|
|
},
|
|
{
|
|
name: "clock",
|
|
testMatch: /clock\.spec\.ts$/,
|
|
dependencies: ["chromium"],
|
|
use: { ...devices["Desktop Chrome"], channel: process.env.PLAYWRIGHT_CHANNEL || undefined },
|
|
},
|
|
],
|
|
webServer: {
|
|
// 只啟動正式建置;build 與測試資料庫由 `npm run test:e2e:prepare` 事先準備,避免每次測試都重新 build。
|
|
command: `npx next start -p ${E2E_PORT}`,
|
|
url: `http://localhost:${E2E_PORT}`,
|
|
env: e2eEnv,
|
|
reuseExistingServer: !process.env.CI,
|
|
timeout: 60_000,
|
|
},
|
|
});
|