小编Jit*_*dra的帖子

如何使用 MockStore 和 MemoizedSelector 在 Angular 8 单元测试中模拟 @ngrx/store 状态

我正在尝试使用 RXJS 在 Angular 8 中使用 jest 创建单元测试。我想模拟商店。我正在使用https://ngrx.io/guide/store/testing使用模拟选择器的示例。谁能帮助我如何使用 MemoizedSelector 和 MockStore 独立使用模拟商店。

 this.store.select(homeState).pipe(select(s => s.checkStatus)).subscribe(status => {
     console.log(status);
     // We performation other action.
});
Run Code Online (Sandbox Code Playgroud)

我在这个组件中有很多选择器。如何模拟许多选择器并更新每个测试用例的选择器值?

unit-testing mocking ngrx ngrx-store angular8

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

angular8 ×1

mocking ×1

ngrx ×1

ngrx-store ×1

unit-testing ×1