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.
  • Loading branch information
dgp1130 committed Aug 29, 2024
1 parent 7f570c5 commit a9b7bbc
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 @@ -146,6 +146,12 @@ export function execute(
logger: context.logger,
};

// 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.

const parsedKarmaConfig = await karma.config.parseConfig(
options.karmaConfig && path.resolve(context.workspaceRoot, options.karmaConfig),
transforms.karmaOptions ? transforms.karmaOptions(karmaOptions) : karmaOptions,
Expand Down Expand Up @@ -208,9 +214,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 a9b7bbc

Please sign in to comment.