-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathplaywright.config.ts
executable file
·136 lines (127 loc) · 3.29 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import { PlaywrightTestConfig, devices, expect } from "@playwright/test";
import dotenv from "dotenv";
dotenv.config();
const config: PlaywrightTestConfig = {
globalSetup: "./global-setup",
globalTeardown: "./global-teardown",
projects: [
{
name: "projectA",
use: { ...devices.use, browserName: "chromium" },
},
{
name: "flakey",
testMatch: /flakey.fail.ts/,
use: {
...devices.use,
browserName: "chromium",
},
},
],
use: {
baseURL: process.env.APP_URL,
browserName: "chromium",
headless: true,
permissions: ["clipboard-read"],
// userAgent: "some custom ua",
navigationTimeout: 10000,
actionTimeout: 5000,
launchOptions: {
args: [
"--disable-dev-shm-usage",
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-gpu",
],
},
screenshot: "on",
viewport: { width: 1280, height: 720 },
ignoreHTTPSErrors: true,
video: "on",
trace: "on",
// extraHTTPHeaders: { playwright: "yes" },
testIdAttribute: "data-qa",
},
testDir: "./tests",
snapshotPathTemplate:
"{testDir}/.screenshots/{testFilePath}/{platform}-{projectName}{arg}{ext}",
retries: 1,
workers: 2,
// grep: /@happy|@smoke/,
reporter: process.env.CI
? [
[
"./node_modules/playwright-slack-report/dist/src/SlackReporter.js",
{
channels: ["slack-testing"], // provide one or more Slack channels
sendResults: "always", // "always" , "on-failure", "off"
},
],
["dot"],
["list"],
["html"],
["playwright-json-summary-reporter"],
["blob"],
["@currents/playwright"],
]
: [
["list"],
["html", { open: "never" }],
["playwright-json-summary-reporter"],
["blob"],
],
forbidOnly: !!process.env.CI, //This will fail if 'test.only' is committed to repo
};
expect.extend({
toBeString(received: string) {
const check = typeof received == "string";
if (check) {
return {
message: () => "passed",
pass: true,
};
} else {
return {
message: () =>
`toBeString() assertion failed.\nYou expected '${received}' to be a string but it's a ${typeof received}\n`,
pass: false,
};
}
},
});
expect.extend({
toBeOneOfValues(received: any, array: any[]) {
const check = array.includes(received);
if (check) {
return {
message: () => "passed",
pass: true,
};
} else {
return {
message: () =>
`toBeOneOfValues() assertion failed.\nYou expected [${array}] to include '${received}'\n`,
pass: false,
};
}
},
});
expect.extend({
toBeValidDate(received: string) {
const pass =
Date.parse(received) && typeof received === "string" ? true : false;
if (pass) {
return {
message: () => "passed",
pass: true,
};
} else {
return {
message: () =>
`toBeValidDate() assertion failed.\nYou expected '${received}' to be a valid date.\n`,
pass: false,
};
}
},
});
export default config;