Files
advanced-camera-card/scripts/browsers.ts
T
Dermot Duffy 2d124fe3cd test: Add a test harness for the built card (#2653)
Mounts the card from `dist/` the way Home Assistant does, by URL with a
HACS tag, and asserts the entry stays a facade, that no chunk imports
it, that the browser is served the file unmodified, and that the card
starts up and fetches a language chunk lazily.

Runs in Chromium, Firefox and WebKit, so a change of bundler or minifier
is checked against every engine.
2026-08-03 21:50:21 -07:00

28 lines
809 B
TypeScript

const BROWSERS = ['chromium', 'firefox', 'webkit'] as const;
export type Browser = (typeof BROWSERS)[number];
const isValidBrowser = (name: string): name is Browser =>
BROWSERS.some((browser) => browser === name);
/**
* Which browsers to run, all of them unless one is named. CI names one per job
* so that the three run at the same time on separate machines rather than one
* after another on one.
*
* Shared by every suite that mounts the card, so that naming a browser means
* the same thing to each of them.
*/
export const getBrowsers = (): readonly Browser[] => {
const requested = process.env.VITEST_BROWSER;
if (requested === undefined) {
return BROWSERS;
}
if (!isValidBrowser(requested)) {
throw new Error(`Unknown browser: ${requested}`);
}
return [requested];
};