Skip to content

Commit e2c5c03

Browse files
committed
fix(@angular-devkit/build-angular): clear context in Karma by default for single run executions
This works around #28271. (cherry picked from commit 3ee2163)
1 parent 88501f3 commit e2c5c03

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

+6-3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ export function execute(
9999

100100
karmaOptions.singleRun = singleRun;
101101

102+
// Workaround https://github.com/angular/angular-cli/issues/28271, by clearing context by default
103+
// for single run executions. Not clearing context for multi-run (watched) builds allows the
104+
// Jasmine Spec Runner to be visible in the browser after test execution.
105+
karmaOptions.client ??= {};
106+
karmaOptions.client.clearContext ??= singleRun ?? false; // `singleRun` defaults to `false` per Karma docs.
107+
102108
// Convert browsers from a string to an array
103109
if (typeof options.browsers === 'string' && options.browsers) {
104110
karmaOptions.browsers = options.browsers.split(',');
@@ -209,9 +215,6 @@ function getBuiltInKarmaConfig(
209215
'karma-coverage',
210216
'@angular-devkit/build-angular/plugins/karma',
211217
].map((p) => workspaceRootRequire(p)),
212-
client: {
213-
clearContext: false, // leave Jasmine Spec Runner output visible in browser
214-
},
215218
jasmineHtmlReporter: {
216219
suppressAll: true, // removes the duplicated traces
217220
},

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

-1
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)