-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaywright.config.ts
157 lines (152 loc) · 4.23 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/**
* GPLv3 License, Copyright (c) 2023 - 2024 Heiko Lübbe
* WordPress-plugin random-quote-zitat-service, see https://github.com/muhme/quote_wordpress
*
* playwright.config.ts - Playwright configuration for E2E tests
* @see ./test
*/
import { defineConfig, devices } from '@playwright/test';
import * as path from 'path';
// admin login and cookie storage
export const STORAGE_STATE =
process.env.WP_ADMIN_AUTH_STORAGE ??
path.join( __dirname, '.playwright_auth.json' );
export const ADMIN_USER = process.env.WP_ADMIN_USERNAME ?? 'admin';
export const ADMIN_PASSWORD = process.env.WP_ADMIN_PASSWORD ?? 'admin';
// WordPress base URL
export const BASE_URL =
process.env.WP_BASE_URL ?? 'http://host.docker.internal:4080';
// see https://playwright.dev/docs/test-configuration
export default defineConfig( {
testDir: 'test',
// 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 : 0,
// opt out of parallel tests on CI
workers: process.env.CI ? 1 : undefined,
// reporter to use, see https://playwright.dev/docs/test-reporters
reporter: [ [ 'html', { open: 'never' } ], [ 'list' ] ],
// shared settings, see https://playwright.dev/docs/api/class-testoptions.
use: {
// use relative paths in tests, see
// https://playwright.dev/docs/test-webserver#adding-a-baseurl
baseURL: BASE_URL,
// save as much information as possible to make debugging easier, see
// https://playwright.dev/docs/api/class-testoptions
screenshot: 'only-on-failure',
trace: 'retain-on-failure',
video: 'retain-on-failure',
},
projects: [
// using project dependencies to have global login setup,
// see https://playwright.dev/docs/test-global-setup-teardown
{
name: 'login-setup',
testMatch: 'test/login.setup.ts',
},
// major browser tests, starting without login
{
name: 'chromium-logged-out',
testMatch: 'test/*.logged.out.spec.ts',
use: {
...devices[ 'Desktop Chrome' ],
},
},
{
name: 'firefox-logged-out',
testMatch: 'test/*.logged.out.spec.ts',
use: {
...devices[ 'Desktop Firefox' ],
},
},
{
name: 'webkit-logged-out',
testMatch: 'test/*.logged.out.spec.ts',
use: {
...devices[ 'Desktop Safari' ],
},
},
// tests against mobile viewports
{
name: 'mobile-chrome-logged-out',
testMatch: 'test/*.logged.out.spec.ts',
use: {
...devices[ 'Pixel 5' ],
},
},
{
name: 'mobile-safari-logged-out',
testMatch: 'test/*.logged.out.spec.ts',
use: {
...devices[ 'iPhone 12' ],
},
},
// major browsers tests, logged in
{
name: 'chromium-logged-in',
testMatch: 'test/*.logged.in.spec.ts',
dependencies: [ 'login-setup' ],
use: {
storageState: STORAGE_STATE,
...devices[ 'Desktop Chrome' ],
},
},
{
name: 'firefox-logged-in',
testMatch: 'test/*.logged.in.spec.ts',
dependencies: [ 'login-setup' ],
use: {
storageState: STORAGE_STATE,
...devices[ 'Desktop Firefox' ],
},
},
{
name: 'webkit-logged-in',
testMatch: 'test/*.logged.in.spec.ts',
dependencies: [ 'login-setup' ],
use: {
storageState: STORAGE_STATE,
...devices[ 'Desktop Safari' ],
},
},
// test against mobile viewports
{
name: 'mobile-chrome-logged-in',
testMatch: 'test/*.logged.in.spec.ts',
dependencies: [ 'login-setup' ],
use: {
storageState: STORAGE_STATE,
...devices[ 'Pixel 5' ],
},
},
{
name: 'mobile-safari-logged-in',
testMatch: 'test/*.logged.in.spec.ts',
dependencies: [ 'login-setup' ],
use: {
storageState: STORAGE_STATE,
...devices[ 'iPhone 12' ],
},
},
// test against branded browsers - only local installed, not available in quote_wp_playwright
// {
// name: 'Microsoft Edge',
// testMatch: 'test/*.logged.in.spec.ts',
// dependencies: ['login setup'],
// use: {
// storageState: STORAGE_STATE,
// ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// testMatch: 'test/*.logged.in.spec.ts',
// dependencies: ['login setup'],
// use: {
// storageState: STORAGE_STATE,
// ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],
} );