You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

54 lines
1.5 KiB

import { defineConfig, devices } from "@playwright/test";
import { readFileSync, existsSync } from "node:fs";
import path from "node:path";
const ROOT = path.resolve(import.meta.dirname, "..");
// 加载 .env.test(不覆盖已有值)
const envPath = path.join(ROOT, ".env.test");
if (existsSync(envPath)) {
const content = readFileSync(envPath, "utf-8");
for (const line of content.split("\n")) {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith("#")) continue;
const eqIdx = trimmed.indexOf("=");
if (eqIdx === -1) continue;
const key = trimmed.slice(0, eqIdx).trim();
const value = trimmed.slice(eqIdx + 1).trim();
if (!(key in process.env)) {
process.env[key] = value;
}
}
}
const PORT = process.env.NITRO_PORT || "3400";
const BASE_URL = process.env.APP_URL || `http://localhost:${PORT}`;
export default defineConfig({
testDir: "./specs",
fullyParallel: false,
workers: 1,
reporter: "html",
globalSetup: "./global-setup.ts",
globalTeardown: "./global-teardown.ts",
use: {
baseURL: BASE_URL,
trace: "on-first-retry",
screenshot: "only-on-failure",
video: "retain-on-failure",
launchOptions: {
env: {
LD_LIBRARY_PATH: [
"/home/dash/.cache/ms-playwright/chromium_headless_shell-1148/chrome-linux",
process.env.LD_LIBRARY_PATH,
].filter(Boolean).join(":"),
},
},
},
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
],
});