Skip to content

Commit 16c8ee2

Browse files
committed
feat(@angular/build): add headless mode for vitest browser mode
1 parent ca83796 commit 16c8ee2

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

packages/angular/build/src/builders/unit-test/builder.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,15 @@ function findBrowserProvider(
331331
}
332332
}
333333

334+
function normalizeBrowserName(browserName: string): string {
335+
// Normalize browser names to match Vitest's expectations for headless but also supports karma's names
336+
// e.g., 'ChromeHeadless' -> 'chrome', 'FirefoxHeadless'
337+
// and 'Chrome' -> 'chrome', 'Firefox' -> 'firefox'.
338+
const normalized = browserName.toLowerCase();
339+
340+
return normalized.replace(/headless$/, '');
341+
}
342+
334343
function setupBrowserConfiguration(
335344
browsers: string[] | undefined,
336345
debug: boolean,
@@ -378,8 +387,10 @@ function setupBrowserConfiguration(
378387
const browser = {
379388
enabled: true,
380389
provider,
390+
headless: browsers.some((name) => name.toLowerCase().includes('headless')),
391+
381392
instances: browsers.map((browserName) => ({
382-
browser: browserName,
393+
browser: normalizeBrowserName(browserName),
383394
})),
384395
};
385396

packages/angular/build/src/builders/unit-test/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"enum": ["karma", "vitest"]
2020
},
2121
"browsers": {
22-
"description": "A list of browsers to use for test execution. If undefined, jsdom on Node.js will be used instead of a browser.",
22+
"description": "A list of browsers to use for test execution. If undefined, jsdom on Node.js will be used instead of a browser. For Vitest and Karma, browser names ending with 'Headless' (e.g., 'ChromeHeadless') will enable headless mode for that browser.",
2323
"type": "array",
2424
"items": {
2525
"type": "string"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy