-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.js
More file actions
102 lines (96 loc) · 3.38 KB
/
Copy pathplaywright.config.js
File metadata and controls
102 lines (96 loc) · 3.38 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
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
/**
* Playwright config for Start Stackable e2e.
*
* WordPress is provided by `@wp-playground/cli` (WASM PHP + SQLite) via
* `webServer` - no Docker, MySQL, or local WP install required.
*
* `WP_BASE_URL` must be set before `@wordpress/e2e-test-utils-playwright` is
* first imported (it reads `process.env.WP_BASE_URL` at module load time).
*
* See e2e/readme.md.
*/
const path = require( 'path' )
const { defineConfig, devices } = require( '@playwright/test' )
const E2E_PROFILE = process.env.E2E_PROFILE || 'standalone'
const E2E_PROFILES = {
standalone: {
blueprint: 'e2e/playground-blueprint.json',
defaultPort: '9430',
serverTimeout: 180,
storageState: 'e2e/.auth/admin.json',
testIgnore: [ '**/onboarding.spec.ts', '**/woocommerce.spec.ts' ],
testMatch: '**/*.spec.ts',
},
woocommerce: {
blueprint: 'e2e/playground-woocommerce-blueprint.json',
defaultPort: '9431',
serverTimeout: 360,
storageState: 'e2e/.auth/admin-woocommerce.json',
testMatch: '**/woocommerce.spec.ts',
},
onboarding: {
blueprint: 'e2e/playground-onboarding-blueprint.json',
defaultPort: '9432',
serverTimeout: 180,
storageState: 'e2e/.auth/admin-onboarding.json',
testMatch: '**/onboarding.spec.ts',
},
}
const PROFILE = E2E_PROFILES[ E2E_PROFILE ]
if ( ! PROFILE ) {
throw new Error( `Unknown E2E_PROFILE "${ E2E_PROFILE }".` )
}
// Distinct from Stackable (9420), Cimo (9410), and the other local profiles.
const PORT = process.env.WP_PORT || PROFILE.defaultPort
const baseURL = process.env.WP_BASE_URL || `http://127.0.0.1:${ PORT }`
process.env.WP_BASE_URL = baseURL
process.env.WP_USERNAME = process.env.WP_USERNAME || 'admin'
process.env.WP_PASSWORD = process.env.WP_PASSWORD || 'password'
process.env.THEME_SLUG = process.env.THEME_SLUG || 'start-stackable'
const STORAGE_STATE_PATH = path.join( __dirname, PROFILE.storageState )
process.env.STORAGE_STATE_PATH = STORAGE_STATE_PATH
const PLAYGROUND_BLUEPRINT = path.join( __dirname, PROFILE.blueprint )
const PHP_VERSION = process.env.WP_PHP_VERSION || '8.2'
const WP_VERSION = process.env.WP_VERSION || 'latest'
module.exports = defineConfig( {
testDir: './e2e/tests',
testMatch: PROFILE.testMatch,
testIgnore: PROFILE.testIgnore,
globalSetup: require.resolve( './e2e/config/global-setup.js' ),
fullyParallel: false,
forbidOnly: !! process.env.CI,
retries: process.env.CI ? 1 : 0,
workers: 1,
timeout: 90_000,
reporter: process.env.CI
? [ [ 'github' ], [ 'html', { open: 'never' } ] ]
: [ [ 'list' ], [ 'html', { outputFolder: 'playwright-report', open: 'never' } ] ],
reportSlowTests: null,
webServer: {
command: [
'npx @wp-playground/cli server',
`--mount=${ JSON.stringify( `.:/wordpress/wp-content/themes/${ process.env.THEME_SLUG }` ) }`,
`--blueprint=${ JSON.stringify( PLAYGROUND_BLUEPRINT ) }`,
`--php=${ PHP_VERSION }`,
`--wp=${ WP_VERSION }`,
`--port=${ PORT }`,
'--workers=1',
].join( ' ' ),
// Use `port`, not `url`: Playground auto-login 302-loops cookie-less probes.
// The authenticated global setup waits for WooCommerce when that profile is active.
port: Number( PORT ),
reuseExistingServer: ! process.env.CI,
timeout: PROFILE.serverTimeout * 1000,
stdout: 'pipe',
stderr: 'pipe',
},
use: {
baseURL,
storageState: STORAGE_STATE_PATH,
ignoreHTTPSErrors: true,
screenshot: 'only-on-failure',
trace: 'retain-on-failure',
video: 'retain-on-failure',
...devices[ 'Desktop Chrome' ],
},
} )