Skip to content

Commit 05184d9

Browse files
committed
Switch nonDefinedThemes counter to a cdn health check
1 parent 0f1b5e4 commit 05184d9

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

test/examples/vanilla/features/themes.spec.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,35 @@ const THEMES: Array<{
2929
{ file: 'themes/demuxed-2022-theme.html', element: 'media-theme-demuxed-2022', hasNativeVideo: false },
3030
];
3131

32-
let nonDefinedThemes = 0;
32+
let cdnAvailable = true;
33+
34+
// A single upfront check avoids a module-level counter that gets reset when
35+
// Playwright restarts a worker for retries.
36+
test.beforeAll(async ({ request }) => {
37+
try {
38+
const res = await request.head('https://cdn.jsdelivr.net/npm/@player.style/yt/+esm');
39+
cdnAvailable = res.ok();
40+
} catch {
41+
cdnAvailable = false;
42+
}
43+
});
44+
3345
for (const { file, element, hasNativeVideo } of THEMES) {
3446
test.describe(`${file}`, () => {
3547
test.beforeEach(async ({ page }) => {
3648
await page.goto(`/examples/vanilla/${file}`, { waitUntil: 'load' });
3749
});
3850

39-
test(`${element} is registered as a custom element`, async ({ page }) => {
51+
test.only(`${element} is registered as a custom element`, async ({ page }) => {
4052
const defined = await page.evaluate(
4153
(tag) => !!customElements.get(tag),
4254
element
4355
);
4456

4557
if (!defined) {
46-
nonDefinedThemes++;
47-
48-
if (nonDefinedThemes === THEMES.length) {
49-
test.fail(true, "Themes are not defined");
58+
if (cdnAvailable) {
59+
test.fail(true, `${element} failed to register despite CDN being reachable`);
5060
} else {
51-
// CDN unavailable — skip rather than fail
5261
test.skip();
5362
}
5463
return;

0 commit comments

Comments
 (0)