Skip to content

Commit ea864e4

Browse files
committed
feat(@angular-devkit/build-angular): add support for --no-browsers in karma builder
This commit enables users to disable runnings tests against a browsers. This can be done by using the `--no-browsers` command line flag or setting `browsers` to `false` in the `angular.json` Closes #26537
1 parent 4ec0224 commit ea864e4

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

packages/angular_devkit/build_angular/src/builders/karma/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ export function execute(
100100
karmaOptions.singleRun = singleRun;
101101

102102
// Convert browsers from a string to an array
103-
if (options.browsers) {
103+
if (typeof options.browsers === 'string' && options.browsers) {
104104
karmaOptions.browsers = options.browsers.split(',');
105+
} else if (options.browsers === false) {
106+
karmaOptions.browsers = [];
105107
}
106108

107109
if (options.reporters) {

packages/angular_devkit/build_angular/src/builders/karma/schema.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,18 @@
199199
"description": "Do not use the real path when resolving modules. If unset then will default to `true` if NodeJS option --preserve-symlinks is set."
200200
},
201201
"browsers": {
202-
"type": "string",
203-
"description": "Override which browsers tests are run against."
202+
"description": "Override which browsers tests are run against. Set to `false` to not use any browser.",
203+
"oneOf": [
204+
{
205+
"type": "string",
206+
"description": "A comma seperate list of browsers to run against."
207+
},
208+
{
209+
"const": false,
210+
"type": "boolean",
211+
"description": "Does use run tests against a browser."
212+
}
213+
]
204214
},
205215
"codeCoverage": {
206216
"type": "boolean",

0 commit comments

Comments
 (0)