Skip to content

Commit fb06bb5

Browse files
teoeterjkrems
authored andcommitted
feat(@angular/build): add headless mode for vitest browser mode
1 parent 851ffc8 commit fb06bb5

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
@@ -333,6 +333,15 @@ function findBrowserProvider(
333333
}
334334
}
335335

336+
function normalizeBrowserName(browserName: string): string {
337+
// Normalize browser names to match Vitest's expectations for headless but also supports karma's names
338+
// e.g., 'ChromeHeadless' -> 'chrome', 'FirefoxHeadless'
339+
// and 'Chrome' -> 'chrome', 'Firefox' -> 'firefox'.
340+
const normalized = browserName.toLowerCase();
341+
342+
return normalized.replace(/headless$/, '');
343+
}
344+
336345
function setupBrowserConfiguration(
337346
browsers: string[] | undefined,
338347
debug: boolean,
@@ -380,8 +389,10 @@ function setupBrowserConfiguration(
380389
const browser = {
381390
enabled: true,
382391
provider,
392+
headless: browsers.some((name) => name.toLowerCase().includes('headless')),
393+
383394
instances: browsers.map((browserName) => ({
384-
browser: browserName,
395+
browser: normalizeBrowserName(browserName),
385396
})),
386397
};
387398

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