-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
135 lines (124 loc) · 4.87 KB
/
playwright.config.ts
File metadata and controls
135 lines (124 loc) · 4.87 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
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
/**
* ---------------------------------------------------------------------
*
* GLPI - Gestionnaire Libre de Parc Informatique
*
* http://glpi-project.org
*
* @copyright 2015-2026 Teclib' and contributors.
* @licence https://www.gnu.org/licenses/gpl-3.0.html
*
* ---------------------------------------------------------------------
*
* LICENSE
*
* This file is part of GLPI.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* ---------------------------------------------------------------------
*/
import { defineConfig, devices } from '@playwright/test';
import { config } from 'dotenv' ;
import { globSync } from 'glob';
import { Config } from './tests/e2e/utils/Config';
// Load .env file so it is available everywhere.
config({path: './tests/e2e/.env.local', quiet: true});
config({path: './tests/e2e/.env', quiet: true});
/**
* Playwright configuration file
*
* See:
* - https://playwright.dev/docs/test-configuration.
* - https://playwright.dev/docs/api/class-testconfig
*/
export default defineConfig({
// Directory that will be recursively scanned for test files.
// See: https://playwright.dev/docs/api/class-testconfig#test-config-test-dir
testDir: './tests/e2e/specs',
// Run tests in files in parallel
// See: https://playwright.dev/docs/api/class-testconfig#test-config-fully-parallel
fullyParallel: true,
// Fail the build on CI if you accidentally left test.only in the source code.
// See: https://playwright.dev/docs/api/class-testconfig#test-config-forbid-only
forbidOnly: !!process.env.CI,
// Retry on CI only
// See: https://playwright.dev/docs/api/class-testconfig#test-config-retries
retries: process.env.CI ? 2 : 0,
// Reporter to use.
// See:
// - https://playwright.dev/docs/test-reporters
// - https://playwright.dev/docs/api/class-testconfig#test-config-reporter
reporter: process.env.CI ? [
// Blob reporter for merging sharded reports
// See: https://playwright.dev/docs/test-sharding#merging-reports-from-multiple-shards
['blob'],
// Easier to read in the terminal output of the CI itself
['dot'],
] : [
// Generate html report in given folder
['html', {
// Disable the report being opened automatically on failure.
// You can enable it with the PLAYWRIGHT_HTML_OPEN=on-failure env
// variable if needed.
open: 'never',
outputFolder: 'tests/e2e/results',
}],
],
// 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('/')`
// See: https://playwright.dev/docs/api/class-testoptions#test-options-base-url
baseURL: Config.getBaseUrl(),
// Collect trace when retrying the failed test.
// See: https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
// Folder for test artifacts such as screenshots, videos, traces, etc.
// See: https://playwright.dev/docs/api/class-testconfig#test-config-output-dir
// Note: must be different than the `outputFolder` folder specified in the HTML
// reporter.
outputDir: 'tests/e2e/output',
// Test projets, for now we run all our tests in a single projet that uses
// chromium.
// See: https://playwright.dev/docs/test-projects
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
viewport: {
width: 1920,
height: 1080,
},
},
},
// Dynamically create a project for each plugin that contains Playwright specs.
...globSync('plugins/*/tests/e2e/**/*.spec.ts')
.map((spec_path) => spec_path.split('/')[1])
.filter((plugin, index, plugins) => plugins.indexOf(plugin) === index)
.map((plugin) => ({
name: `plugin:${plugin}`,
testDir: `./plugins/${plugin}/tests/e2e/specs`,
use: {
...devices['Desktop Chrome'],
viewport: {
width: 1920,
height: 1080,
},
},
})),
],
});