| 
									
										
										
										
											2022-03-13 20:26:13 -08:00
										 |  |  | const { test, expect } = require('@playwright/test'); | 
					
						
							| 
									
										
										
										
											2022-03-11 15:46:11 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | const { spawn } = require('child_process'); | 
					
						
							|  |  |  | const fs = require('fs'); | 
					
						
							|  |  |  | const path = require('path'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | for (const dir of fs.readdirSync(__dirname)) { | 
					
						
							|  |  |  |   const folder = path.join(__dirname, dir); | 
					
						
							|  |  |  |   if (!fs.statSync(folder).isDirectory()) | 
					
						
							|  |  |  |     continue; | 
					
						
							|  |  |  |   test.describe.serial(path.basename(folder), () => { | 
					
						
							| 
									
										
										
										
											2022-05-03 22:04:43 -07:00
										 |  |  |     test.setTimeout(7 * 60 * 1000 /* 7 minutes */); | 
					
						
							| 
									
										
										
										
											2022-03-11 15:46:11 -08:00
										 |  |  |     test('install', async () => { | 
					
						
							|  |  |  |       await run('npm', ['i'], folder); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-10-20 22:33:25 +02:00
										 |  |  |     test('typecheck', async () => { | 
					
						
							|  |  |  |       await run('npm', ['run', 'typecheck'], folder); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-11 15:46:11 -08:00
										 |  |  |     for (const project of ['chromium', 'firefox', 'webkit']) { | 
					
						
							|  |  |  |       test(project, async () => { | 
					
						
							|  |  |  |         await run('npx', ['playwright', 'test', '--project=' + project, '--reporter=list'], folder); | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2022-10-20 22:33:25 +02:00
										 |  |  |     }  | 
					
						
							| 
									
										
										
										
											2022-03-11 15:46:11 -08:00
										 |  |  |   }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | async function run(command, args, folder) { | 
					
						
							|  |  |  |   const child = spawn(command, args, { | 
					
						
							|  |  |  |     cwd: folder, | 
					
						
							|  |  |  |     stdio: 'pipe', | 
					
						
							|  |  |  |     shell: true, | 
					
						
							|  |  |  |     env: process.env | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   child.stdout.on('data', data => process.stdout.write(data)); | 
					
						
							|  |  |  |   child.stderr.on('data', data => process.stdout.write(data)); | 
					
						
							|  |  |  |   process.on('exit', () => { | 
					
						
							|  |  |  |     child.kill(); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2022-03-13 20:26:13 -08:00
										 |  |  |   const code = await new Promise(f => child.on('close', f)); | 
					
						
							|  |  |  |   expect(code).toEqual(0); | 
					
						
							| 
									
										
										
										
											2022-03-11 15:46:11 -08:00
										 |  |  | } |