Skip to content

Commit a9b7bbc

Browse files
committed
fix(@angular-devkit/build-angular): clear context in Karma by default for single run executions
This works around angular#28271.
1 parent 7f570c5 commit a9b7bbc

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ export function execute(
146146
logger: context.logger,
147147
};
148148

149+
// Workaround https://github.com/angular/angular-cli/issues/28271, by clearing context by default
150+
// for single run executions. Not clearing context for multi-run (watched) builds allows the
151+
// Jasmine Spec Runner to be visible in the browser after test execution.
152+
karmaOptions.client ??= {};
153+
karmaOptions.client.clearContext ??= singleRun ?? false; // `singleRun` defaults to `false` per Karma docs.
154+
149155
const parsedKarmaConfig = await karma.config.parseConfig(
150156
options.karmaConfig && path.resolve(context.workspaceRoot, options.karmaConfig),
151157
transforms.karmaOptions ? transforms.karmaOptions(karmaOptions) : karmaOptions,
@@ -208,9 +214,6 @@ function getBuiltInKarmaConfig(
208214
'karma-coverage',
209215
'@angular-devkit/build-angular/plugins/karma',
210216
].map((p) => workspaceRootRequire(p)),
211-
client: {
212-
clearContext: false, // leave Jasmine Spec Runner output visible in browser
213-
},
214217
jasmineHtmlReporter: {
215218
suppressAll: true, // removes the duplicated traces
216219
},

packages/schematics/angular/config/files/karma.conf.js.template

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module.exports = function (config) {
1919
// for example, you can disable the random execution with `random: false`
2020
// or set a specific seed with `seed: 4321`
2121
},
22-
clearContext: false // leave Jasmine Spec Runner output visible in browser
2322
},
2423
jasmineHtmlReporter: {
2524
suppressAll: true // removes the duplicated traces

0 commit comments

Comments
 (0)