-
Couldn't load subscription status.
- Fork 11.9k
fix(@angular/build): allow custom runner configuration file for unit-test #31603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…test Adds a new `runnerConfig` option to the `unit-test` system to provide more control over the test runner's configuration file. This option is runner-agnostic and enhances flexibility for both Vitest and Karma. The option accepts a boolean or a string path: - `true`: Automatically searches for a default config file (`karma.conf.js` or `vitest.config.ts`). If not found, the runner will use its internal default configuration. - `false` (default): Disables the use of any external config file. - `path/to/config`: Uses the specified configuration file. For Vitest, the loaded configuration is deep-merged with the system's programmatic config. This allows users to add or override advanced options (like `test.coverage`) while preserving the essential in-memory integration. The system's settings take precedence in case of conflicts. Please note that while the file is loaded, the Angular team does not provide direct support for its specific contents or any third-party plugins used within it. Informational messages are now logged to indicate which configuration file is being used, improving transparency.
90e8dcf to
cb8727e
Compare
|
Nice one @clydin, thanks! Just one thing. To avoid user and tool confusion, what about naming it differently (e.g.
|
|
This is opt-in and the name can be configured to an arbitrary value. If there is need to avoid it being picked up by other tools (some actually may want it picked up), it can be named something different. Also of relevance, this is more of a "base" rather than an override. Options specified on command execution take precedence which follows the behavior of Vitest. |
| "enum": ["karma", "vitest"] | ||
| }, | ||
| "runnerConfig": { | ||
| "type": ["boolean", "string"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Not sure how to handle this, but having type both boolean or string will make runnerConfig config not possible to be used from the CLI. As options cannot be either boolean or string.
|
Agreed, something like a I am actually concerned about the default name. Newcomers and AI-generated code will more likely pick |
|
Initial goal here was consistency as the Angular CLI has used the existing |
Adds a new
runnerConfigoption to theunit-testsystem to provide more control over the test runner's configuration file. This option is runner-agnostic and enhances flexibility for both Vitest and Karma.The option accepts a boolean or a string path:
true: Automatically searches for a default config file (karma.conf.jsorvitest.config.ts). If not found, the runner will use its internal default configuration.false(default): Disables the use of any external config file.path/to/config: Uses the specified configuration file.For Vitest, the loaded configuration is deep-merged with the system's programmatic config. This allows users to add or override advanced options (like
test.coverage) while preserving the essential in-memory integration. The system's settings take precedence in case of conflicts.Please note that while the file is loaded, the Angular team does not provide direct support for its specific contents or any third-party plugins used within it.
Informational messages are now logged to indicate which configuration file is being used, improving transparency.
Closes #31392