【发布时间】:2018-03-30 12:02:30
【问题描述】:
我最近升级了我的 Angular 应用程序的 Angular 包,其中涉及升级:
- 来自
4.0.0的所有@angular/*包=>4.4.5 - @angular-redux/store 包来自
6.1.0=>6.5.7
在角度 4.0.0 和 NgRedux 6.1.0 中,这曾经可以工作:
store = new NgRedux<IAppState>(null);
store.configureStore(reducerConfig, undefined);
// etc.
但显然,他们创建了 NgRedux 类 abstract。因此,我的单元测试将失败并出现以下异常:Cannot create an instance of the abstract class 'NgRedux'.
我尝试使用Testing Redux - Testing Simple Actions 中提议的自定义模拟类来修复我的测试:
class MockRedux extends NgRedux<any> {
constructor() {
super(null);
}
dispatch = () => undefined;
}
但是,由于没有实现所有抽象成员,因此失败:
[ts] Non-abstract class 'MockRedux' does not implement inherited abstract member 'configureSubStore' from class 'NgRedux<any>'.
那么问题来了:如何在我的角度规范中正确地模拟一个带有 NgRedux 的 redux 存储?
【问题讨论】:
-
看看这个medium blog
标签: angular unit-testing redux