From 4a1e96aa5d5702eeee01cc38519e0df29bb86490 Mon Sep 17 00:00:00 2001 From: Hans Larsen Date: Fri, 28 Sep 2018 14:36:55 -0400 Subject: [PATCH] feat(@angular-devkit/build-angular): add --reporters option to test It was a regression, and used by enough people on CI. No reason it should be omitted and karma.conf.js only. Fixes #11376 --- packages/angular/cli/lib/config/schema.json | 7 +++++++ packages/angular_devkit/build_angular/src/karma/index.ts | 7 +++++++ .../angular_devkit/build_angular/src/karma/schema.d.ts | 5 +++++ .../angular_devkit/build_angular/src/karma/schema.json | 7 +++++++ 4 files changed, 26 insertions(+) diff --git a/packages/angular/cli/lib/config/schema.json b/packages/angular/cli/lib/config/schema.json index cb898d3c7041..ba1c6a7b66e6 100644 --- a/packages/angular/cli/lib/config/schema.json +++ b/packages/angular/cli/lib/config/schema.json @@ -1261,6 +1261,13 @@ ] }, "default": [] + }, + "reporters": { + "type": "array", + "description": "Karma reporters to use. Directly passed to the karma runner.", + "items": { + "type": "string" + } } }, "additionalProperties": false, diff --git a/packages/angular_devkit/build_angular/src/karma/index.ts b/packages/angular_devkit/build_angular/src/karma/index.ts index df1138edc85a..3d1b066d9f1b 100644 --- a/packages/angular_devkit/build_angular/src/karma/index.ts +++ b/packages/angular_devkit/build_angular/src/karma/index.ts @@ -71,6 +71,13 @@ export class KarmaBuilder implements Builder { karmaOptions.browsers = options.browsers.split(','); } + if (options.reporters) { + // Split along commas to make it more natural, and remove empty strings. + karmaOptions.reporters = options.reporters + .reduce((acc, curr) => acc.concat(curr.split(/,/)), []) + .filter(x => !!x); + } + const sourceRoot = builderConfig.sourceRoot && resolve(root, builderConfig.sourceRoot); karmaOptions.buildWebpack = { diff --git a/packages/angular_devkit/build_angular/src/karma/schema.d.ts b/packages/angular_devkit/build_angular/src/karma/schema.d.ts index 650e05c3d6c7..4ea24b6afe19 100644 --- a/packages/angular_devkit/build_angular/src/karma/schema.d.ts +++ b/packages/angular_devkit/build_angular/src/karma/schema.d.ts @@ -32,4 +32,9 @@ export interface KarmaBuilderSchema extends Pick