Skip to content

Commit 204794c

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 angular#26537
1 parent 78d1720 commit 204794c

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

goldens/public-api/angular_devkit/build_angular/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export interface FileReplacement {
271271
// @public
272272
export interface KarmaBuilderOptions {
273273
assets?: AssetPattern_3[];
274-
browsers?: string;
274+
browsers?: Browsers;
275275
codeCoverage?: boolean;
276276
codeCoverageExclude?: string[];
277277
exclude?: string[];

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

+3-1
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

+12-2
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 tests 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)