如何解决“在角度单位测试中未定义的''includes'错误”

时间:2019-09-10 13:12:20

标签: angular-unit-test

我正在编写遇到茉莉花错误的单元测试用例

这是针对角度应用的,不确定发生这种情况的原因

错误

Uncaught Error: Uncaught (in promise): TypeError: Cannot read property 'includes' of undefined
        TypeError: Cannot read property 'includes' of undefined
            at includes src/app/customer-details-v2/customer-details-v2.component.ts:236:41)
            at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke node_modules/zone.js/dist/zone.js:391:1)
            at ProxyZoneSpec.push../node_modules/zone.js/dist/zone-testing.js.ProxyZoneSpec.onInvoke node_modules/zone.js/dist/zone-testing.js:289:1)
            at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke node_modules/zone.js/dist/zone.js:390:1)
            at Object.onInvoke node_modules/@angular/core/fesm5/core.js:17299:1)
            at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke node_modules/zone.js/dist/zone.js:390:1)
            at Zone../node_modules/zone.js/dist/zone.js.Zone.run node_modules/zone.js/dist/zone.js:150:1)
            at http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone.js:889:1
            at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask node_modules/zone.js/dist/zone.js:423:1)
            at ProxyZoneSpec.push../node_modules/zone.js/dist/zone-testing.js.ProxyZoneSpec.onInvokeTask node_modules/zone.js/dist/zone-testing.js:320:1) thrown
        TypeError: Cannot read property 'includes' of undefined
            at includes src/app/customer-details-v2/customer-details-v2.component.ts:236:41)
            at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke node_modules/zone.js/dist/zone.js:391:1)
            at AsyncTestZoneSpec.push../node_modules/zone.js/dist/zone-testing.js.AsyncTestZoneSpec.onInvoke node_modules/zone.js/dist/zone-testing.js:714:1)
            at ProxyZoneSpec.push../node_modules/zone.js/dist/zone-testing.js.ProxyZoneSpec.onInvoke node_modules/zone.js/dist/zone-testing.js:286:1)
            at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke node_modules/zone.js/dist/zone.js:390:1)
            at Object.onInvoke node_modules/@angular/core/fesm5/core.js:17299:1)
            at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke node_modules/zone.js/dist/zone.js:390:1)
            at Zone../node_modules/zone.js/dist/zone.js.Zone.run node_modules/zone.js/dist/zone.js:150:1)
            at http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone.js:889:1
            at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask node_modules/zone.js/dist/zone.js:423:1)
            at ZoneDelegate../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask node_modules/zone.js/dist/zone.js:423:1)

该错误应该不会发生

0 个答案:

没有答案