Skip to content

fix(@angular/build): apply build conditions to the Karma unit-test ru… - #34843

Open
damienwebdev wants to merge 1 commit into
angular:mainfrom
damienwebdev:fix/unit-test-karma-conditions
Open

damienwebdev wants to merge 1 commit into
angular:mainfrom
damienwebdev:fix/unit-test-karma-conditions

Conversation

@damienwebdev

@damienwebdev damienwebdev commented Dec 4, 2026 •

Copy link
Copy Markdown

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

With runner: karma, the unit-test builder copies a fixed set of options from the build target into the Karma build, and conditions is not one of them. Packages with conditional exports resolve their default exports in Karma tests, while ng build uses the build target's conditions.

Fixes: #34836

What is the new behavior?

The Karma runner passes the build target's conditions to the Karma test build.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Reproduction: https://github.com/damienwebdev/angular-cli-conditions-repro/tree/karma. With this change, the test in src/app/app.spec.ts passes.

@angular/build:karma used directly still has no way to set conditions. Supporting it would mean adding a public conditions option to its schema and passing it the same way. I can follow up with that if it's wanted.

…nner

The Karma runner of the unit-test builder copies a fixed set of options from
the build target, and `conditions` was not one of them. Pass it through to
the Karma test build.

Fixes angular#34836

@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 introduces support for custom resolve conditions in the Karma builder. It defines a new KarmaBuilderInternalOptions type that extends the standard Karma builder options with the conditions property from the build target options. These conditions are then propagated through the Karma executor and setup build options. A new behavior test suite is also added to verify that packages are correctly resolved using these custom conditions. There are no review comments, so I have no feedback to provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Karma test builds ignore conditions

1 participant