Repository navigation
Conversation
…ration Karma migration The Karma to Vitest migration moves build-only test options such as `styles` into a `testing` build configuration and points the test target at it. For each test configuration it created a separate `testing-<name>` build configuration containing only that configuration's own options. Because a test configuration's `buildTarget` replaces the base one, running `ng test --configuration <name>` lost the options moved from the base test options. Merge the base options into each per-configuration build configuration, with the configuration's own values taking precedence.
There was a problem hiding this comment.
Code Review
This pull request updates the Karma to Vitest migration schematic to correctly handle inheritance of base test options in per-configuration build settings. It ensures that custom build options are properly merged, preventing potential configuration loss. The review feedback highlights a potential issue with spreading undefined base options and provides a safer implementation using a guard clause.
| // A test configuration inherits the base test options, so its build configuration must | ||
| // include the build options moved from them, with the configuration's own values on top. | ||
| const mergedOptions = configKey | ||
| ? { ...customBuildOptions[''], ...configOptions } |
There was a problem hiding this comment.
styles case is fixed but aot comes back - processTestTargetOptions seeds every config entry with { aot: false, optimization: false, extractLicenses: false }, so seeded aot: false of ci wins over explicit aot: true from base here
test options { styles, aot: true } + ci: { watch: false } gives testing with aot: true and testing-ci with aot: false, so ng test runs AOT and ng test -c ci runs JIT. same for optimization and extractLicenses
new spec doesnt set aot so it passes either way
seeding Karma defaults only for base entry looks enough, configs then get them through this merge (checked on 22.3.0-next.2 with it patched in):
customBuildOptions[configKey] = configKey
? {}
: {
aot: false,
optimization: false,
extractLicenses: false,
};There was a problem hiding this comment.
Thanks, you're right. The seeded aot: false in each configuration overrode an explicit base value. Applied your suggestion so the Karma defaults are seeded only for the base entry, and configurations now inherit them through the merge.
One addition: when the test target has no base options, allTargetOptions doesn't yield a base entry, so there's nothing to inherit from. In that case configurations are still seeded (configKey && testTarget.options ? {} : { … }), otherwise their testing- build configurations would switch to AOT.
Added specs for both: base { styles, aot: true } + ci: { watch: false } now gives aot: true in both testing and testing-ci (it failed before the change), and a target with only configurations keeps aot: false.
ac2914d to
8df4cb6
Compare
…configuration Karma migration
…configuration Karma migration
8df4cb6 to
5846b18
Compare
The Karma to Vitest migration moves build-only test options such as
stylesinto atestingbuild configuration and points the test target at it. For each test configuration it created a separatetesting-<name>build configuration containing only that configuration's own options. Because a test configuration'sbuildTargetreplaces the base one, runningng test --configuration <name>lost the options moved from the base test options.Merge the base options into each per-configuration build configuration, with the configuration's own values taking precedence.