using BuilderContext from @angular-devkit/architect to run angular unit test converts undefined to default type value #32652
Description
Activity
- addedarea: build & ciRelated the build and CI infrastructure of the projectRelated the build and CI infrastructure of the projectgemini-triagedLabel noting that an issue has been triaged by geminiLabel noting that an issue has been triaged by gemini
on Mar 3, 2026 - addedarea: build & ciRelated the build and CI infrastructure of the projectRelated the build and CI infrastructure of the projectgemini-triagedLabel noting that an issue has been triaged by geminiLabel noting that an issue has been triaged by gemini
on Mar 3, 2026 - removedarea: build & ciRelated the build and CI infrastructure of the projectRelated the build and CI infrastructure of the projectgemini-triagedLabel noting that an issue has been triaged by geminiLabel noting that an issue has been triaged by gemini
on Mar 3, 2026 Since
ng testalready handles the full project suite, could you clarify the specific need for a separate builder in this case? Without a runnable reproduction, it’s difficult to diagnose the issue you're seeing with your custom builder.Regarding the logic: the conversion from
undefinedto[]is intentional, and there is currently no configuration to disable this behavior- addedneeds: more infoReporter must clarify the issueReporter must clarify the issue
on Mar 3, 2026 We’re using a custom builder as an orchestration layer over ng test because we need to override certain parameters when running the full project suite — for example, enabling coverage (and additional suite-specific options) only during full-suite execution, while keeping individual library test runs lightweight. different lib with different config when ran for entire project suite.
any other builder i can use that would allow me to perform this and not have this
undefined to []and still override the optionsWe'd require a minimal reproduction to investigate.
You can read here why this is needed. A good way to make a minimal repro is to create a new app via
ng new repro-appand adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.This might be related to your directory structure so its really important to get an accurate repro to diagnose this.
@alan-agius4 https://github.com/BharathSubu/angular-build-issue-repo
after setup try running ng run mylib:test and ng run repro-app:test-all
ng run my-lib:test Initial chunk files | Names | Raw size chunk-CGZBV6BD.js | - | 4.07 kB | spec-lib-my-lib.js | spec-lib-my-lib | 1.66 kB | init-testbed.js | init-testbed | 1.21 kB | vitest-mock-patch.js | vitest-mock-patch | 481 bytes | | Initial total | 7.42 kB Application bundle generation complete. [2.079 seconds] - 2026-03-04T10:22:31.802Z Watch mode enabled. Watching for file changes... DEV v4.0.18 D:/Personal/repro-app ✓ my-lib projects/my-lib/src/lib/my-lib.spec.ts (1 test) 33ms ✓ MyLib (1) ✓ should create 32ms Test Files 1 passed (1) Tests 1 passed (1) Start at 15:52:32 Duration 1.83s (transform 87ms, setup 432ms, import 22ms, tests 33ms, environment 1.12s)ng run repro-app:test-all Running target "my-lib:test"... Initial chunk files | Names | Raw size chunk-CGZBV6BD.js | - | 4.07 kB | spec-lib-my-lib.js | spec-lib-my-lib | 1.66 kB | init-testbed.js | init-testbed | 1.21 kB | vitest-mock-patch.js | vitest-mock-patch | 481 bytes | | Initial total | 7.42 kB Application bundle generation complete. [1.249 seconds] - 2026-03-04T10:21:21.658Z Watch mode enabled. Watching for file changes... An exception occurred during test execution: Error: The "browsers" option requires either "playwright" or "webdriverio" to be installed within the project. Please install one of these packages and rerun the test command.In the reproduction provided I am only seeing a single project and no custom builders.
@alan-agius4 sry , i missed to push the changes, could you check now pls
Reacted by Alan Agius- added a commit that references this issue
on Mar 4, 2026 - added a commit that references this issue
on Mar 4, 2026 Actually I just realized that there other properties with this issue
- added a commit that references this issue
on Mar 4, 2026 - removedneeds: more infoReporter must clarify the issueReporter must clarify the issue
on Mar 4, 2026 true , i observed this with coverageIncludes too , guess anything undefined need to be handled when passing thru the builder
I’ve investigated the behavior, and it appears that coverageIncludes remains unaffected. Both undefined and empty arrays are currently handled identically within the logic.
angular-automatic-lock-bot commented
on Apr 5, 2026 More actionsThis issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
- locked and limited conversation to collaborators
on Apr 5, 2026
Which @angular/* package(s) are the source of the bug?
Don't known / other
Is this a regression?
Yes
Description
i have multiple libs so for each lib the unit test is running using @angular/build:unit-test in jsdom , like this
"test": { "builder": "@angular/build:unit-test", "options": { "tsConfig": "libs/mylib/tsconfig.spec.json", "runnerConfig": "libs/mylib/vitest.config.ts", "watch": false } },to run all utest of all libs im using
"test-all": { "builder": "dist:build-all", "options": { "targets": [ mylib:test , mylib1:test ] } },this dist:build-all uses BuilderContext from @angular-devkit/architect
await this.context.scheduleTarget(target, overrides);
issue is when running mylib:test the test run fines , but when running project:test-all
angular unit test fails with list of supported browser not specified
the issue
when running mylib:test the parameter passed to @angular/build:unit-test is browser = undefined
but when running project:test-all the parameter passed to @angular/build:unit-test is browser = []
coz internally await this.context.scheduleTarget(target, overrides); convert undefined to default value i guess here it is []
so is there any way i can make sure this conversion doesnt happen , or specify @angular/build:unit-test to not run the test in browser
this issue also happend when coverageIncludes is not specified , when ran using @angular/build:unit-test
coverageIncludes is undefined , but when ran using await this.context.scheduleTarget(target, overrides); the value passed is [] and coverage is not reported
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version)Anything else?
No response