哪个@angular/*包是bug的来源?
core, zone.js
这是个回归吗?
是的
描述
我正在测试一个带有(基于信号)必需输入的组件。当没有为必需输入提供值时,它应该抛出一个NG0950错误。在zone变更检测的情况下是这样,但当使用provideExperimentalZonelessChangeDetection()
时,测试意外地成功了。
经过检查日志后,我看到记录了NG0950错误,但测试仍然成功。
我认为这可能与#56240有关。
请提供一个最小复现bug的链接
https://stackblitz.com/edit/stackblitz-starters-pdwsvu?file=src%2Fapp%2Fapp.component.spec.ts
请提供您看到的异常或错误
> 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
请提供您发现此bug的环境(运行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
还有其他信息吗?
- 无响应*
3条答案
按热度按时间drnojrws1#
请从我这里消除一个疑问,在zone应用程序中,当调用
fixture.detectChanges()
时会抛出错误,对吗?ltqd579y2#
Take away a doubt from me, in the zone app, the error is thrown when you call
fixture.detectChanges()
right ?Yes, see the same repro for the zone app:
https://stackblitz.com/edit/stackblitz-starters-tp2ugc?file=src%2Fapp%2Fapp.component.spec.ts
lhcgjxsq3#
所以,基本上这和 #56240 的根源是相同的。
在 zone app 中,它是
detectChanges()
,一个在触发错误的测试中调用的功能。在无区域测试的情况下,错误是由
ApplicationRef.tick
触发的,它将所有内容 Package 在一个 try-catch 块中,并将错误记录到 ErrorHandler。在无区域应用中进行测试本身就是一个需要一些工作的主题。你可以找到 some details here。