-
Notifications
You must be signed in to change notification settings - Fork 0
/
playwright.config.ts
77 lines (70 loc) · 2.21 KB
/
playwright.config.ts
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/* eslint-env node*/
import { PlaywrightTestConfig, defineConfig, devices } from "@playwright/test";
import path from "node:path";
/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig<unknown, unknown> = {
testDir: "./tests/e2e",
fullyParallel: true,
retries: 0,
timeout: 30 * 1000,
outputDir: "tmp/integration/playwright/test-results/",
reporter: [
["list"],
[
"html",
{ outputFolder: "tmp/integration/playwright/report", open: "never" }
]
],
projects: [
{
name: "Firefox",
use: { ...devices["Desktop Firefox"] }
},
{
name: "Google Chrome",
use: { ...devices["Desktop Chrome"], channel: "chrome" }
},
{
name: "Mobile Chrome",
use: { ...devices["Pixel 5"] }
}
],
expect: {
toHaveScreenshot: {
stylePath: ["tests/e2e/e2e.css"]
}
},
use: {}
};
//
// https://playwright.dev/docs/api/class-testconfig#test-config-snapshot-path-template
//
// See node_modules/playwright/lib/common/config.js #155
// const defaultSnapshotPathTemplate = '{snapshotDir}/{testFileDir}/{testFileName}-snapshots/{arg}{-projectName}{-snapshotSuffix}{ext}';
// [...] snapshotDir: takeFirst(pathResolve(configDir, projectConfig.snapshotDir), pathResolve(configDir, config.snapshotDir), testDir),
//
if (process.env["CI"]) {
/* Fail the build on CI if you accidentally left test.only in the source code. */
config.forbidOnly = true;
// Traces: See https://playwright.dev/docs/trace-viewer#opening-the-trace
// https://trace.playwright.dev/
config.retries = 3;
config.use!.trace = "retain-on-failure";
config.ignoreSnapshots = false;
if (process.env["GITHUB_ACTIONS"]) {
(config.reporter as Array<any>).push(["github"]);
config.snapshotDir = path.join(config.testDir!, "/__github__");
} else if (process.env["GITLAB_CI"]) {
// config.retries = 1;
// (config.reporter as Array<any>).push(["gitlab"]);
config.snapshotDir = path.join(config.testDir!, "/__gitlab__");
} else {
console.warn("Mode: CI but unidentified runner !!");
}
} else {
// config.ignoreSnapshots = true;
config.snapshotDir = path.join(config.testDir!, "/__local__");
}
export default defineConfig(config);