尝试运行简单的单元测试以创建组件时获取此错误代码。以前从未遇到过这种情况。
测试用例场景:
it('should create component')
控制台显示错误:
Chrome 74.0.3729 (Windows 7.0.0) BranchMgmtComponent should create FAILED
Uncaught TypeError: Cannot read property 'length' of undefined thrown
检查模板HTML文件中是否有任何无人看管的length属性,但没有。 **。ts **文件中没有未分配长度的属性。 ngOnInit内几乎没有服务调用,也尝试将其删除并进行模拟,但没有帮助。
Uncaught TypeError: Cannot read property length of undefined
at :9876/ karma_webpack...n/fesm5/http.js:108
at Array.forEach (<anonymous>)
at HttpHeaders.lazyInit (:9876/ karma_webpack...n/fesm5/http.js:102)
at HttpHeader.init ( :9876/ karma_webpack...n/fesm5/http.js:166)
at HttpHeader.forEach ( :9876/ karma_webpack...n/fesm5/http.js:235)
at Observable.subscribe ( :9876/ karma_webpack...n/fesm5/http.js:1435)
.....
需要帮助。最近3天都在此特定问题上卡住了。 如果需要其他详细信息,请告诉我。