无法阅读财产“每一个' Angular 2测试中未定义的

时间:2017-01-25 02:40:08

标签: angular karma-jasmine

我正在为我的组件编写测试。我有以下错误。

Cannot read property 'every' of undefined

在我的.ts中,我使用了每一个'如下:

constructor(
    private store: Store<any>,
    private modalService: NgbModal,
  ) {
    const assetStore$ = this.store.select('cmsAsset');
    // Filter is a dirty hack to remove bad entities left in place by 'Create'
    this.cmsAssetEntities$ = assetStore$.let(reducers.getCmsAssets)
      .filter(assets => assets.every(asset => Object.keys(asset).length > 0));
  }

我不知道在.spec文件中要做什么来解决错误。请指教!

1 个答案:

答案 0 :(得分:3)

.filter(assets => assets && assets.every(asset => Object.keys(asset).length > 0));