Skip to content

feat(@angular/build): add runnerArgs option to unit-test builder - #34717

Open
clydin wants to merge 2 commits into
angular:mainfrom
clydin:unit-test-runner-args
Open

clydin wants to merge 2 commits into
angular:mainfrom
clydin:unit-test-runner-args

Conversation

@clydin

@clydin clydin commented Nov 13, 2026

Copy link
Copy Markdown
Member

The unit-test builder now supports a runnerArgs option that provides
additional command line arguments to the Vitest runner. For example,
ng test --runner-args=--update updates existing snapshots and
ng test --runner-args=--bail=1 stops the run after the first failure.
The option can also be configured within the angular.json file.

The arguments are parsed with the Vitest command line parser and then
validated against a list of supported Vitest options. The Vitest parser
accepts unknown options, command names, and test file filters without
error. The validation ensures that a misspelled or unsupported argument
fails the build with a descriptive message instead of being ignored.
Vitest options with an equivalent builder option, such as --reporter
and --coverage, are rejected with a reference to the builder option.

The initially supported Vitest options are --allowOnly, --bail,
--disableConsoleIntercept, --expandSnapshotDiff, --maxWorkers,
--printConsoleTrace, --retry, --sequence.seed,
--sequence.shuffle, --shard, --testTimeout, and --update.

The supported options take precedence over a Vitest configuration file
but not over the other builder options. The option is not available for
the Karma runner.

…cutor

The Vitest CLI level options were assembled inline within the Vitest
executor's initialization. They are now created by a dedicated function
which allows the mapping from the builder options to be unit tested
without starting Vitest. There is no change in behavior.
@clydin clydin added the target: minor This PR is targeted for the next minor release label Nov 13, 2026
@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: @angular/build labels Nov 13, 2026
@clydin
clydin force-pushed the unit-test-runner-args branch from 374dfa5 to c0dbeb7 Compare November 13, 2026 19:54
The unit-test builder now supports a `runnerArgs` option that provides
additional command line arguments to the Vitest runner. For example,
`ng test --runner-args=--update` updates existing snapshots and
`ng test --runner-args=--bail=1` stops the run after the first failure.
The option can also be configured within the `angular.json` file.

The arguments are parsed with the Vitest command line parser and then
validated against a list of supported Vitest options. The Vitest parser
accepts unknown options, command names, and test file filters without
error. The validation ensures that a misspelled or unsupported argument
fails the build with a descriptive message instead of being ignored.
Vitest options with an equivalent builder option, such as `--reporter`
and `--coverage`, are rejected with a reference to the builder option.

The initially supported Vitest options are `--allowOnly`, `--bail`,
`--disableConsoleIntercept`, `--expandSnapshotDiff`, `--maxWorkers`,
`--printConsoleTrace`, `--retry`, `--sequence.seed`,
`--sequence.shuffle`, `--shard`, `--testTimeout`, and `--update`.

The supported options take precedence over a Vitest configuration file
but not over the other builder options. The option is not available for
the Karma runner.
@clydin
clydin force-pushed the unit-test-runner-args branch from c0dbeb7 to 5452b1a Compare November 13, 2026 20:19
@clydin
clydin marked this pull request as ready for review November 13, 2026 20:39
@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Nov 13, 2026

@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 a new runnerArgs option to the Angular unit-test builder, allowing users to pass additional command-line arguments to the Vitest runner. It includes validation logic to ensure only a supported subset of Vitest CLI options are allowed. Feedback on the changes highlights an issue with the color option validation, which currently prevents users from explicitly disabling colors (e.g., via --no-color or --color=false). A code suggestion has been provided to properly handle boolean values for the color option.

@clydin
clydin requested a review from alan-agius4 November 13, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/build detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant