Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): clear context in Karma by default…
Browse files Browse the repository at this point in the history
… for single run executions

This works around angular#28271.

(cherry picked from commit 3ee2163)
  • Loading branch information
dgp1130 committed Aug 29, 2024
1 parent 88501f3 commit 4af6814
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ export function execute(

karmaOptions.singleRun = singleRun;

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

// Convert browsers from a string to an array
if (typeof options.browsers === 'string' && options.browsers) {
karmaOptions.browsers = options.browsers.split(',');
Expand Down Expand Up @@ -209,9 +215,6 @@ function getBuiltInKarmaConfig(
'karma-coverage',
'@angular-devkit/build-angular/plugins/karma',
].map((p) => workspaceRootRequire(p)),
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true, // removes the duplicated traces
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ module.exports = function (config) {
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
Expand Down

0 comments on commit 4af6814

Please sign in to comment.