Skip to content

Zoneless tests with unset required inputs succeeds unexpectedly #56977

@szacskesz

Description

@szacskesz

Which @angular/* package(s) are the source of the bug?

core, zone.js

Is this a regression?

Yes

Description

I am testing a component with (signal based) required inputs. When no value is provided to the required input, it should throw an NG0950 error. With zone change detection it was the case, but when the provideExperimentalZonelessChangeDetection() is used, the tests succeeds unexpectedly.

After examining the logs I see the NG0950 error logged, but the test still succeeds.
I believe it might be related to #56240

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/stackblitz-starters-pdwsvu?file=src%2Fapp%2Fapp.component.spec.ts

Please provide the exception or error you saw

> ng test

✔ Browser application bundle generation complete.
13 07 2024 15:41:47.999:WARN [karma]: No captured browser, open http://localhost:9876/
13 07 2024 15:41:48.010:INFO [karma-server]: Karma v6.4.3 server started at http://localhost:9876/
13 07 2024 15:41:48.010:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
13 07 2024 15:41:48.012:INFO [launcher]: Starting browser Chrome
13 07 2024 15:41:48.525:INFO [Chrome 126.0.0.0 (Windows 10)]: Connected on socket PaQI-IqyyYwYYJJcAAAB with id 11717700
ERROR: 'ERROR', Error: NG0950: Input is required but no value is available yet. Find more at https://angular.dev/errors/NG0950
Error: NG0950: Input is required but no value is available yet. Find more at https://angular.dev/errors/NG0950
    at AppComponent.inputValueFn [as a2] (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:98:19)
    at templateFn (ng:///AppComponent.js:111:54)
    at executeTemplate (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:11620:9)
    at refreshView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:13238:13)
    at detectChangesInView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:13454:9)
    at detectChangesInViewIfAttached (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:13414:5)
    at detectChangesInComponent (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:13403:5)
    at detectChangesInChildComponents (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:13467:9)
    at refreshView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:13292:13)
    at detectChangesInView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:13454:9)
Chrome 126.0.0.0 (Windows 10): Executed 0 of 1 SUCCESS (0 secs / 0 secs)
ERROR: 'ERROR', Error: NG0950: Input is required but no value is available yet. Find more at https://angular.dev/errors/NG0950
Error: NG0950: Input is required but no value is available yet. Find more at https://angular.dev/errors/NG0950
    at AppComponent.inputValueFn [as a2] (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:98:19)
    at templateFn (ng:///AppComponent.js:111:54)
    at executeTemplate (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:11620:9)
    at refreshView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:13238:13)
    at detectChangesInView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:13454:9)
    at detectChangesInViewIfAttached (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:13414:5)
    at detectChangesInComponent (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:13403:5)
    at detectChangesInChildComponents (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:13467:9)
    at refreshView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2022/core.mjs:13292:13)
Chrome 126.0.0.0 (Windows 10): Executed 1 of 1 SUCCESS (0.531 secs / 0.424 secs)
TOTAL: 1 SUCCESS

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 18.1.0
Node: 20.15.0
Package Manager: npm 10.7.0
OS: win32 x64

Angular: 18.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1801.0
@angular-devkit/build-angular   18.1.0
@angular-devkit/core            18.1.0
@angular-devkit/schematics      18.1.0
@schematics/angular             18.1.0
rxjs                            7.8.1
typescript                      5.5.3
zone.js                         0.14.7

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: testingIssues related to Angular testing features, such as TestBedcore: zonelessIssues related to running Angular without zone.js

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions