@@ -35,11 +35,18 @@ const buildWebServerEnv = () => {
3535 return env
3636}
3737
38+ const workersHighParallel = process . env [ 'GITHUB_ACTIONS' ] ? 1 : '75%'
39+ const testMatchHighParallel = '**/*.spec.ts'
40+ const testIgnoreHighParallel = [
41+ '03-forms/**/*.spec.ts' ,
42+ '05-api/**/*.spec.ts' ,
43+ '06-actions/**/*.spec.ts' ,
44+ ]
45+ const testMatchSerial = [ '03-forms/**/*.spec.ts' ]
46+
3847export default defineConfig ( {
39- /* Look for test files in the "tests" directory, relative to this configuration file. */
48+ /** Look for test files in the "tests" directory, relative to this configuration file. */
4049 testDir : './test/e2e/specs' ,
41- /* Glob patterns or regular expressions that match test files. */
42- testMatch : '**/*.spec.ts' ,
4350 /** Folder for test artifacts such as screenshots, videos, traces, etc. */
4451 outputDir : `.cache/playwright/output/` ,
4552 /** Tracked by Git LFS */
@@ -53,17 +60,17 @@ export default defineConfig({
5360 */
5461 timeout : 5000 ,
5562 } ,
56- /* Run tests in files in parallel */
63+ /** Run tests in files in parallel */
5764 fullyParallel : true ,
58- /* Fail the build on CI if you accidentally left test.only in the source code. */
65+ /** Fail the build on CI if you accidentally left test.only in the source code. */
5966 forbidOnly : ! ! process . env [ 'GITHUB_ACTIONS' ] ,
60- /* Retry on CI only */
67+ /** Retry on CI only */
6168 retries : process . env [ 'GITHUB_ACTIONS' ] ? 2 : 0 ,
62- /* Opt out of parallel tests on CI. */
63- workers : process . env [ 'GITHUB_ACTIONS' ] ? 1 : '75%' ,
64- /* Only run @ready tests in CI, all tests locally */
69+ /** Opt out of parallel tests on CI. */
70+ workers : workersHighParallel ,
71+ /** Only run @ready tests in CI, all tests locally */
6572 ...( process . env [ 'GITHUB_ACTIONS' ] ? { grep : / @ r e a d y / } : { } ) ,
66- /* Reporter to use. See https://playwright.dev/docs/test-reporters */
73+ /** Reporter to use. See https://playwright.dev/docs/test-reporters */
6774 reporter : process . env [ 'GITHUB_ACTIONS' ]
6875 ? 'github'
6976 : isCIMode
@@ -76,59 +83,166 @@ export default defineConfig({
7683 [ 'html' , { outputFolder : `.cache/playwright/reports/` } ] ,
7784 [ 'json' , { outputFile : '.cache/playwright/results.json' } ] ,
7885 ] ,
79- /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
86+ /** Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
8087 use : {
8188 /** Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
8289 actionTimeout : 0 ,
83- /* Base URL to use in actions like `await page.goto('/')`. */
90+ /** Base URL to use in actions like `await page.goto('/')`. */
8491 baseURL : 'http://localhost:4321' ,
8592 ignoreHTTPSErrors : true ,
8693 /** Capture screenshot after each test failure, other options are 'on' and 'off'. */
8794 screenshot : 'only-on-failure' ,
88- /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
95+ /** Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
8996 trace : 'on-first-retry' ,
9097 } ,
9198
92- /* Configure projects for major browsers */
9399 projects : [
100+ /**
101+ * ===========================================================================================
102+ *
103+ * Most tests run in parallel across all major browsers
104+ *
105+ * ==========================================================================================
106+ */
94107 {
95108 name : 'chromium' ,
96109 use : { ...devices [ 'Desktop Chrome' ] } ,
110+ testMatch : testMatchHighParallel ,
111+ testIgnore : testIgnoreHighParallel ,
97112 } ,
98113
99114 {
100115 name : 'firefox' ,
101116 use : { ...devices [ 'Desktop Firefox' ] } ,
117+ testMatch : testMatchHighParallel ,
118+ testIgnore : testIgnoreHighParallel ,
102119 } ,
103120
104121 {
105122 name : 'webkit' ,
106123 use : { ...devices [ 'Desktop Safari' ] } ,
124+ testMatch : testMatchHighParallel ,
125+ testIgnore : testIgnoreHighParallel ,
107126 } ,
108127
109- /* Test against mobile viewports. */
128+ /** Test against mobile viewports. */
110129 {
111- name : 'Mobile Chrome ' ,
130+ name : 'mobile-chrome ' ,
112131 use : { ...devices [ 'Pixel 5' ] } ,
132+ testMatch : testMatchHighParallel ,
133+ testIgnore : testIgnoreHighParallel ,
113134 } ,
114135 {
115- name : 'Mobile Safari ' ,
136+ name : 'mobile-safari ' ,
116137 use : { ...devices [ 'iPhone 12' ] } ,
138+ testMatch : testMatchHighParallel ,
139+ testIgnore : testIgnoreHighParallel ,
117140 } ,
118141
119- /* Test against branded browsers. */
142+ /** Test against branded browsers. */
120143 {
121- name : 'Microsoft Edge ' ,
144+ name : 'microsoft-edge ' ,
122145 use : { ...devices [ 'Desktop Edge' ] , channel : 'msedge' } ,
146+ testMatch : testMatchHighParallel ,
147+ testIgnore : testIgnoreHighParallel ,
123148 } ,
124149 {
125- name : 'Google Chrome ' ,
150+ name : 'google-chrome ' ,
126151 use : { ...devices [ 'Desktop Chrome' ] , channel : 'chrome' } ,
152+ testMatch : testMatchHighParallel ,
153+ testIgnore : testIgnoreHighParallel ,
154+ } ,
155+
156+ /**
157+ * ===========================================================================================
158+ *
159+ * These projects are designed to run serially due to database contention issues.
160+ * We use SQLite in tests, which has limited support for concurrent writes.
161+ *
162+ * ===========================================================================================
163+ */
164+
165+ {
166+ name : 'chromium-serial' ,
167+ use : { ...devices [ 'Desktop Chrome' ] } ,
168+ testMatch : testMatchSerial ,
169+ workers : 1 ,
170+ } ,
171+
172+ {
173+ name : 'firefox-serial' ,
174+ use : { ...devices [ 'Desktop Firefox' ] } ,
175+ dependencies : [ 'chromium-serial' ] ,
176+ testMatch : testMatchSerial ,
177+ workers : 1 ,
178+ } ,
179+
180+ {
181+ name : 'webkit-serial' ,
182+ use : { ...devices [ 'Desktop Safari' ] } ,
183+ dependencies : [ 'firefox-serial' ] ,
184+ testMatch : testMatchSerial ,
185+ workers : 1 ,
186+ } ,
187+
188+ /** Test against mobile viewports. */
189+ {
190+ name : 'mobile-chrome-serial' ,
191+ use : { ...devices [ 'Pixel 5' ] } ,
192+ dependencies : [ 'webkit-serial' ] ,
193+ testMatch : testMatchSerial ,
194+ workers : 1 ,
195+ } ,
196+ {
197+ name : 'mobile-safari-serial' ,
198+ use : { ...devices [ 'iPhone 12' ] } ,
199+ dependencies : [ 'mobile-chrome-serial' ] ,
200+ testMatch : testMatchSerial ,
201+ workers : 1 ,
202+ } ,
203+
204+ /** Test against branded browsers. */
205+ {
206+ name : 'microsoft-edge-serial' ,
207+ use : { ...devices [ 'Desktop Edge' ] , channel : 'msedge' } ,
208+ dependencies : [ 'mobile-safari-serial' ] ,
209+ testMatch : testMatchSerial ,
210+ workers : 1 ,
211+ } ,
212+ {
213+ name : 'google-chrome-serial' ,
214+ use : { ...devices [ 'Desktop Chrome' ] , channel : 'chrome' } ,
215+ dependencies : [ 'microsoft-edge-serial' ] ,
216+ testMatch : testMatchSerial ,
217+ workers : 1 ,
218+ } ,
219+
220+ /**
221+ * ===========================================================================================
222+ *
223+ * API and Actions tests are only using the browser to fetch so no need to run
224+ * across browsers. They run serially to avoid SQLite write contention issues.
225+ *
226+ * ===========================================================================================
227+ */
228+
229+ {
230+ name : 'api-serial' ,
231+ use : { ...devices [ 'Desktop Chrome' ] } ,
232+ testMatch : '05-api/**/*.spec.ts' ,
233+ workers : 1 ,
234+ } ,
235+
236+ {
237+ name : 'actions-serial' ,
238+ use : { ...devices [ 'Desktop Chrome' ] } ,
239+ testMatch : '06-actions/**/*.spec.ts' ,
240+ workers : 1 ,
127241 } ,
128242 ] ,
129243
130- /* Run your local dev server before starting the tests */
131- /* In debug mode, assume server is already running */
244+ /** Run your local dev server before starting the tests */
245+ /** In debug mode, assume server is already running */
132246 ...( isCIMode
133247 ? { }
134248 : {
@@ -144,10 +258,4 @@ export default defineConfig({
144258
145259 globalSetup : './test/e2e/config/global-setup.ts' ,
146260 globalTeardown : './test/e2e/config/global-teardown.ts' ,
147-
148- // path to the global teardown files.
149- //globalTeardown: require.resolve('./global-teardown'),
150-
151- // Each test is given 30 seconds.
152- //timeout: 30000,
153261} )
0 commit comments