|
1 | | -import { chromium } from '@playwright/test'; |
| 1 | +import { chromium, type Browser, type Page } from '@playwright/test'; |
2 | 2 |
|
3 | 3 | /** |
4 | 4 | * Loads the Vite-served QUnit page in headless Chromium and exits nonzero on failures. |
5 | 5 | */ |
6 | 6 | async function main(): Promise<void> { |
7 | | - const browser = await chromium.launch(); |
8 | | - const page = await browser.newPage(); |
| 7 | + const browser: Browser = await chromium.launch(); |
| 8 | + const page: Page = await browser.newPage(); |
9 | 9 |
|
10 | 10 | // Assumes vite dev server is running on 5173 |
11 | | - await page.goto('http://localhost:5173/tests/', {waitUntil: 'domcontentloaded'}); |
| 11 | + await page.goto( |
| 12 | + 'http://localhost:5173/tests/', |
| 13 | + {waitUntil: 'domcontentloaded'}, |
| 14 | + ); |
12 | 15 |
|
13 | | - // Wait for QUnit to finish |
14 | | - await page.waitForFunction(() => (window as any).__qunit_done__ === true, null, {timeout: 120_000}); |
| 16 | + // Wait up to 2 minutes for QUnit to finish. See types/qunit-globals.d.ts for the added python dunders |
| 17 | + await page.waitForFunction( |
| 18 | + () => globalThis.__qunit_done__, // wait until this is Truthy |
| 19 | + null, |
| 20 | + {timeout: 120_000}, // in ms |
| 21 | + ); |
15 | 22 |
|
16 | 23 | const { results, failures } = await page.evaluate(() => ({ |
17 | | - results: (window as any).__qunit_results__, |
18 | | - failures: (window as any).__qunit_failures__ ?? [], |
| 24 | + results: globalThis.__qunit_results__, |
| 25 | + failures: globalThis.__qunit_failures__ ?? [], |
19 | 26 | })); |
20 | 27 | await browser.close(); |
21 | 28 |
|
|
0 commit comments