-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplaywright.config.js
230 lines (179 loc) · 6.09 KB
/
playwright.config.js
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
import { defineConfig, devices } from "@playwright/test";
import path from "path";
import 'dotenv/config';
import { getReportFolder } from './utils/reportManager'
// export const STORAGE_STATE = path.join(__dirname, 'storageState', 'storageState.json');
// export const STORAGE_STATE_CHROMIUM = path.join(__dirname, 'storageState', 'storageState_chromium.json');
export const STORAGE_STATE_CHROMIUM = path.join(__dirname, 'storageState', 'storageState_chromium.json');
// export const STORAGE_STATE_EDGE = path.join(__dirname, 'storageState', 'storageState_edge.json');
export const STORAGE_STATE_FIREFOX = path.join(__dirname, 'storageState', 'storageState_firefox.json');
export const STORAGE_STATE_WEBKIT = path.join(__dirname, 'storageState', 'storageState_webkit.json');
// const playwrightReportFolder = getReportFolder('playwright-report', 10);
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config({ path: path.resolve(__dirname, '.env') });
/**
* @see https://playwright.dev/docs/test-configuration
*/
export default defineConfig({
timeout: 5 * 60 * 1000, // Global 30 sec timeout for all tests
expect: {
timeout: 15 * 1000, // 15 sec Timeout for all expect assertions
},
// globalSetup: require.resolve('./tests/login.setup.js'),
/* Specifies the directory where test files are located */
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 1,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 2 : 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [ ['list'],
['html'],
['allure-playwright'],
],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.STAGE_URL,
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'retain-on-failure',
/* Takes screenshots only when a test fails */
screenshot: 'only-on-failure',
/* Records video only for failed tests and retains it for debugging */
video: 'retain-on-failure',
ignoreHTTPSErrors: true,
viewport: { width: 1280, height: 720 },
},
/* Configure projects for major browsers */
projects: [
/* Chromium browser */
{
name: 'smoke-chromium',
grep: /@smoke/,
use: {
browserName: 'chromium',
},
// testMatch: ['**/homePageTest.spec.js', '**/signupPageTest.spec.js' ],
},
{
name: 'setup-chromium',
grep: /@setup/,
dependencies: ['smoke-chromium'],
use: {
browserName: 'chromium',
},
},
{
name: 'chromium',
use: {
// ...devices['Desktop Chrome'],
browserName: 'chromium',
storageState: STORAGE_STATE_CHROMIUM,
navigationTimeout: 30000,
actionTimeout: 30000,
},
testMatch: '**/*.spec.js',
testIgnore: ['**/loginSetup.spec.js', '**/homePageTest.spec.js', '**/signupPageTest.spec.js'],
// testIgnore: /@smoke/,
dependencies: ['smoke-chromium', 'setup-chromium'],
},
/* Firefox browser */
{
name: 'smoke-firefox',
testMatch: ['**/homePageTest.spec.js', '**/signupPageTest.spec.js'],
use: {
browserName: 'firefox',
}
},
{
name: 'setup-firefox',
testMatch: '**/*.setup.js', // Matches files ending with .setup.js for setup tasks
dependencies: ['smoke-firefox'],
use: {
browserName: 'firefox',
},
},
{
name: 'firefox',
use: {
// ...devices['Desktop Firefox'],
browserName: 'firefox',
storageState: STORAGE_STATE_FIREFOX,
navigationTimeout: 30000,
actionTimeout: 30000,
},
testMatch: '**/*.spec.js',
testIgnore: ['**/homePageTest.spec.js', '**/signupPageTest.spec.js'],
dependencies: ['smoke-firefox', 'setup-firefox'],
},
/* Webkit browser */
{
name: 'smoke-webkit',
testMatch: ['**/homePageTest.spec.js', '**/signupPageTest.spec.js' ],
use: {
browserName: 'webkit',
}
},
{
name: 'setup-webkit',
testMatch: '**/*.setup.js', // Matches files ending with .setup.js for setup tasks
dependencies: ['smoke-webkit'],
use: {
browserName: 'webkit',
}
},
{
name: 'webkit',
use: {
// ...devices['Desktop Safari'],
browserName: 'webkit',
storageState: STORAGE_STATE_WEBKIT,
navigationTimeout: 30000,
actionTimeout: 30000,
},
testMatch: '**/*.spec.js',
testIgnore: ['**/homePageTest.spec.js', '**/signupPageTest.spec.js'],
dependencies: ['smoke-webkit', 'setup-webkit'],
},
///////////////////////////////////////////////////////////////////////
{
name: 'edge',
use: {
// ...devices['Desktop Edge'],
browserName: 'chromium',
channel: 'msedge',
},
},
// {
// name: 'chromium',
// use: { ...devices['Desktop Chrome'],
// storageState: STORAGE_STATE_CHROMIUM,
// },
// testMatch: '**/*.spec.js', // Matches test files ending with .spec.js
// testIgnore: ['**/homePageTest.spec.js', '**/signupPageTest.spec.js'],
// dependencies: ['setup'], // Ensures setup is completed before running these tests
// },
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },
],
/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});