-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
55 lines (50 loc) · 1.91 KB
/
playwright.config.ts
File metadata and controls
55 lines (50 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import path from "path";
import { defineConfig, devices } from "@playwright/test";
import dotenv from "dotenv";
dotenv.config({ path: path.resolve(__dirname, ".env") });
const storageStatePath = path.join(__dirname, "playwright", ".auth", "user.json");
/**
* Non-empty `PUBLIC_PAGE_URL` disables `globalSetup` and `storageState` (no `user.json`).
* Use for public URLs. SharePoint tests normally use `SHAREPOINT_PAGE_URL` + saved auth instead.
*/
const usePublicNoAuth = Boolean(process.env.PUBLIC_PAGE_URL?.trim());
/** Env `PLAYWRIGHT_BROWSER`: `msedge` (default) | `chromium` | `firefox` | `webkit` */
const browser = (process.env.PLAYWRIGHT_BROWSER ?? "msedge").toLowerCase();
function desktopWithChannel() {
if (browser === "firefox") return devices["Desktop Firefox"];
if (browser === "webkit") return devices["Desktop Safari"];
if (browser === "msedge")
return { ...devices["Desktop Edge"], channel: "msedge" as const };
return { ...devices["Desktop Chrome"] };
}
export default defineConfig({
...(usePublicNoAuth
? {}
: { globalSetup: path.join(__dirname, "global-setup.ts") }),
testDir: "./tests",
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [["html", { open: "never" }], ["list"]],
timeout: 120_000,
/** SharePoint UIs often need >20s for web parts and tree data. */
expect: { timeout: 60_000 },
use: {
/** Locally show a real browser (incl. UI Mode). CI stays headless. */
headless: !!process.env.CI,
/** Local: trace every test so HTML/UI can open a trace per test; CI stays lighter. */
trace: process.env.CI ? "on-first-retry" : "on",
screenshot: "only-on-failure",
video: "on-first-retry",
},
projects: [
{
name: "e2e",
use: {
...desktopWithChannel(),
...(usePublicNoAuth ? {} : { storageState: storageStatePath }),
},
},
],
});