(_context: Config)
| 14 | * @see https://playwright.dev/docs/test-advanced#global-setup-and-teardown |
| 15 | */ |
| 16 | export default async function globalSetup(_context: Config): Promise<() => Promise<void>> { |
| 17 | const [runtimeIoResult, previewIoResult] = await Promise.allSettled([runRuntimeServer(), runPreviewServer()]); |
| 18 | |
| 19 | if (runtimeIoResult.status === 'rejected' || previewIoResult.status === 'rejected') { |
| 20 | if (runtimeIoResult.status === 'fulfilled') { |
| 21 | runtimeIoResult.value.kill(); |
| 22 | } else if (previewIoResult.status === 'fulfilled') { |
| 23 | previewIoResult.value.kill(); |
| 24 | } |
| 25 | |
| 26 | if (runtimeIoResult.status === 'rejected') { |
| 27 | throw runtimeIoResult.reason; |
| 28 | } else if (previewIoResult.status === 'rejected') { |
| 29 | throw previewIoResult.reason; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | const cdnProxy = await runSandpackCDNProxy(); |
| 34 | return async () => { |
| 35 | cdnProxy.app.close(); |
| 36 | runtimeIoResult.value.kill(); |
| 37 | previewIoResult.value.kill(); |
| 38 | }; |
| 39 | } |
| 40 | |
| 41 | function runRuntimeServer(): DeferredPromise<ChildProcess> { |
| 42 | return spawnAndWaitForStdout('pnpm', ['start:runtime'], (stdout) => { |
nothing calls this directly
no test coverage detected