Skip to content

Commit 260391f

Browse files
committed
refactor: log warnings for unsupported options in Web Test Runner
This helps notify users when they are attempting to use an option from Karma which hasn't been implemented yet.
1 parent 5b2a8d2 commit 260391f

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import { BuilderContext } from '@angular-devkit/architect';
10+
import { Schema as WtrBuilderOptions } from './schema';
11+
12+
const UNSUPPORTED_OPTIONS: Array<keyof WtrBuilderOptions> = [
13+
'main',
14+
'assets',
15+
'scripts',
16+
'styles',
17+
'inlineStyleLanguage',
18+
'stylePreprocessorOptions',
19+
'sourceMap',
20+
'progress',
21+
'poll',
22+
'preserveSymlinks',
23+
'browsers',
24+
'codeCoverage',
25+
'codeCoverageExclude',
26+
'fileReplacements',
27+
'webWorkerTsConfig',
28+
];
29+
30+
/** Logs a warning for any unsupported options specified. */
31+
export function logBuilderStatusWarnings(options: WtrBuilderOptions, ctx: BuilderContext) {
32+
// Validate supported options
33+
for (const unsupportedOption of UNSUPPORTED_OPTIONS) {
34+
const value = (options as unknown as WtrBuilderOptions)[unsupportedOption];
35+
36+
if (value === undefined || value === false) {
37+
continue;
38+
}
39+
if (Array.isArray(value) && value.length === 0) {
40+
continue;
41+
}
42+
if (typeof value === 'object' && Object.keys(value).length === 0) {
43+
continue;
44+
}
45+
46+
ctx.logger.warn(`The '${unsupportedOption}' option is not yet supported by this builder.`);
47+
}
48+
}

packages/angular_devkit/build_angular/src/builders/web-test-runner/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import path from 'path';
1616
import { findTestFiles } from '../../utils/test-files';
1717
import { buildApplicationInternal } from '../application';
1818
import { OutputHashing } from '../browser-esbuild/schema';
19+
import { logBuilderStatusWarnings } from './builder-status-warnings';
1920
import { WtrBuilderOptions, normalizeOptions } from './options';
2021
import { Schema } from './schema';
2122

@@ -24,6 +25,7 @@ export default createBuilder(
2425
ctx.logger.warn(
2526
'NOTE: The Web Test Runner builder is currently EXPERIMENTAL and not ready for production use.',
2627
);
28+
logBuilderStatusWarnings(schema, ctx);
2729

2830
const options = normalizeOptions(schema);
2931
const testDir = 'dist/test-out';

0 commit comments

Comments
 (0)