Skip to content

fix(@angular/build): only require karma-coverage when coverage is enabled - #34500

Open
MeAkib wants to merge 3 commits into
angular:mainfrom
MeAkib:fix/unit-test-karma-coverage-dependency
Open

MeAkib wants to merge 3 commits into
angular:mainfrom
MeAkib:fix/unit-test-karma-coverage-dependency

Conversation

@MeAkib

@MeAkib MeAkib commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

The upfront dependency validation of the unit-test builder's karma runner checks the truthiness of the normalized coverage option, which is always an object since the introduction of the advanced coverage options. As a result, ng test with the karma runner fails with a MissingDependenciesError requesting the karma-coverage package even when coverage is disabled. Check the enabled property instead, matching the vitest runner and the karma executor. A new unit spec for the karma runner's dependency validation fails without this change.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Karma test runner to check options.coverage.enabled instead of options.coverage when verifying dependencies, and introduces a new unit test suite to validate this behavior. The review feedback suggests simplifying the newly added tests by replacing the asynchronous assertions with synchronous Jasmine matchers, as the validateDependencies method is synchronous.

Comment thread packages/angular/build/src/builders/unit-test/runners/karma/index_spec.ts Outdated
Comment thread packages/angular/build/src/builders/unit-test/runners/karma/index_spec.ts Outdated
@alan-agius4 alan-agius4 added the target: patch This PR is targeted for the next patch release label Oct 23, 2026
@MeAkib
MeAkib requested a review from alan-agius4 October 27, 2026 15:04
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Oct 27, 2026
…bled

The upfront dependency validation of the unit-test builder's karma runner checks
the truthiness of the normalized `coverage` option, which is always an object
since the introduction of the advanced coverage options. As a result, `ng test`
with the karma runner fails with a `MissingDependenciesError` requesting the
`karma-coverage` package even when coverage is disabled. Check the `enabled`
property instead, matching the vitest runner and the karma executor. A new unit
spec for the karma runner's dependency validation fails without this change.
@alan-agius4
alan-agius4 force-pushed the fix/unit-test-karma-coverage-dependency branch from 2526ef4 to 9ab90d0 Compare October 27, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants