Skip to content

Commit 29bd9db

Browse files
committed
fixup! refactor(@angular/build): clean up duplicate of code in the karma builders
1 parent 5e5495a commit 29bd9db

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/angular/build/src/builders/karma/application_builder.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ async function getProjectSourceRoot(context: BuilderContext): Promise<string> {
338338
}
339339

340340
function normalizePolyfills(
341-
polyfills: string[] | undefined = [],
341+
polyfills: string[] = [],
342342
): [polyfills: string[], jasmineCleanup: string[]] {
343343
const jasmineGlobalEntryPoint = localResolve('./polyfills/jasmine_global.js');
344344
const jasmineGlobalCleanupEntrypoint = localResolve('./polyfills/jasmine_global_cleanup.js');
@@ -711,8 +711,6 @@ function getBaseKarmaOptions(
711711
options: NormalizedKarmaBuilderOptions,
712712
context: BuilderContext,
713713
): ConfigOptions {
714-
const singleRun = !options.watch;
715-
716714
// Determine project name from builder context target
717715
const projectName = context.target?.project;
718716
if (!projectName) {
@@ -723,13 +721,14 @@ function getBaseKarmaOptions(
723721
? {}
724722
: getBuiltInKarmaConfig(context.workspaceRoot, projectName);
725723

724+
const singleRun = !options.watch;
726725
karmaOptions.singleRun = singleRun;
727726

728727
// Workaround https://github.com/angular/angular-cli/issues/28271, by clearing context by default
729728
// for single run executions. Not clearing context for multi-run (watched) builds allows the
730729
// Jasmine Spec Runner to be visible in the browser after test execution.
731730
karmaOptions.client ??= {};
732-
karmaOptions.client.clearContext ??= singleRun ?? false; // `singleRun` defaults to `false` per Karma docs.
731+
karmaOptions.client.clearContext ??= singleRun;
733732

734733
// Convert browsers from a string to an array
735734
if (options.browsers) {

0 commit comments

Comments
 (0)