微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

角表组件开玩笑测试未通过cdkTable 10.1.3

如何解决角表组件开玩笑测试未通过cdkTable 10.1.3

我正在用不同的名称“ PsTableComponent”在本地测试MatTable,并尝试运行笑话测试。但是,带有玩笑的PsTableComponent(像原始MatTable组件一样扩展了cdkTable)会产生以下错误

TypeError: Cannot read property 'nativeElement' of undefined
    at PsTableComponent.CdkTable (../src/cdk/table/table.ts:442:24)
      at new PsTableComponent (table.ts:7:1)
      at createClass (../packages/core/src/view/provider.ts:273:14)
      at createDirectiveInstance (../packages/core/src/view/provider.ts:142:7)
      at createViewNodes (../packages/core/src/view/view.ts:314:28)
      at callViewAction (../packages/core/src/view/view.ts:647:7)
      at execComponentViewsAction (../packages/core/src/view/view.ts:570:7)
      at createViewNodes (../packages/core/src/view/view.ts:342:3)
      at createRootView (../packages/core/src/view/view.ts:216:3)
      at callWithDebugContext (../packages/core/src/view/services.ts:638:23)
      at Object.debugCreateRootView [as createRootView] (../packages/core/src/view/services.ts:119:10)
      at ComponentFactory_.Object.<anonymous>.ComponentFactory_.create (../packages/core/src/view/refs.ts:92:27)
      at initComponent (../packages/core/testing/src/test_bed.ts:618:28)
      at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:386:30)
      at ProxyZonespec.Object.<anonymous>.ProxyZonespec.onInvoke (node_modules/zone.js/dist/proxy.js:117:43)
      at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:385:36)
      at Object.onInvoke (../packages/core/src/zone/ng_zone.ts:326:29)
      at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:385:36)
      at Zone.Object.<anonymous>.Zone.run (node_modules/zone.js/dist/zone.js:143:47)
      at ngzone.Object.<anonymous>.ngzone.run (../packages/core/src/zone/ng_zone.ts:180:50)
      at TestbedViewEngine.Object.<anonymous>.TestbedViewEngine.createComponent (../packages/core/testing/src/test_bed.ts:622:56)
      at Function.Object.<anonymous>.TestbedViewEngine.createComponent (../packages/core/testing/src/test_bed.ts:245:36)
      at src/app/mass-payment/receipts/receipts.component.spec.ts:73:23
      at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:386:30)
      at ProxyZonespec.Object.<anonymous>.ProxyZonespec.onInvoke (node_modules/zone.js/dist/proxy.js:117:43)
      at ZoneDelegate.Object.<anonymous>.ZoneDelegate.invoke (node_modules/zone.js/dist/zone.js:385:36)
      at Zone.Object.<anonymous>.Zone.run (node_modules/zone.js/dist/zone.js:143:47)
      at Object.testBody.length (node_modules/jest-preset-angular/zone-patch/index.js:52:27)

哪个会导致cdkTable:

https://github.com/angular/components/blob/10.1.x/src/cdk/table/table.ts#L442

依赖项:

    "@angular/animations": "^10.0.5","@angular/cdk": "^10.1.3","@angular/common": "^10.0.5","@angular/compiler": "^10.0.5","@angular/core": "^10.0.5","@angular/forms": "^10.0.5","@angular/material": "^10.1.1"..

有人知道导致问题的原因吗?

解决方法

您的测试用例中的某处: 例如:

PKCS5Padding

您必须检查yourVariable.nativeCode.(....) 是否实现yourVariable接口。 并且整个测试组件是否正确启动。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。