Skip to content

Commit bdd4f2c

Browse files
dgp1130alan-agius4
authored andcommitted
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 68dae53 commit bdd4f2c

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
'watch',
29+
];
30+
31+
/** Logs a warning for any unsupported options specified. */
32+
export function logBuilderStatusWarnings(options: WtrBuilderOptions, ctx: BuilderContext) {
33+
// Validate supported options
34+
for (const unsupportedOption of UNSUPPORTED_OPTIONS) {
35+
const value = (options as unknown as WtrBuilderOptions)[unsupportedOption];
36+
37+
if (value === undefined || value === false) {
38+
continue;
39+
}
40+
if (Array.isArray(value) && value.length === 0) {
41+
continue;
42+
}
43+
if (typeof value === 'object' && Object.keys(value).length === 0) {
44+
continue;
45+
}
46+
47+
ctx.logger.warn(`The '${unsupportedOption}' option is not yet supported by this builder.`);
48+
}
49+
}

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
@@ -14,6 +14,7 @@ import path from 'node:path';
1414
import { findTestFiles } from '../../utils/test-files';
1515
import { buildApplicationInternal } from '../application';
1616
import { OutputHashing } from '../browser-esbuild/schema';
17+
import { logBuilderStatusWarnings } from './builder-status-warnings';
1718
import { WtrBuilderOptions, normalizeOptions } from './options';
1819
import { Schema } from './schema';
1920

@@ -22,6 +23,7 @@ export default createBuilder(
2223
ctx.logger.warn(
2324
'NOTE: The Web Test Runner builder is currently EXPERIMENTAL and not ready for production use.',
2425
);
26+
logBuilderStatusWarnings(schema, ctx);
2527

2628
// Dynamic import `@web/test-runner` from the user's workspace. As an optional peer dep, it may not be installed
2729
// and may not be resolvable from `@angular-devkit/build-angular`.

0 commit comments

Comments
 (0)