我正在为我的组件编写测试。我有以下错误。
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文件中要做什么来解决错误。请指教!
答案 0 :(得分:3)
试
.filter(assets => assets && assets.every(asset => Object.keys(asset).length > 0));