我正在尝试对我的一个模块进行测试,该模块处理 ngRedux。在运行测试时,我得到
TypeError: this.ngRedux.getState 不是函数
我正在运行的测试很简单
it("should create component:", () => {
expect(comp).toBeDefined();
});
包.json
"redux": "^3.6.0",
"redux-logger": "^2.6.1",
"redux-observable": "^0.12.2",
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage": "^1.1.1",
"karma-jasmine": "^1.1.0",
"karma-mocha-reporter": "^2.2.4",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.4",
"@angular/core": "4.3.6",
组件代码
...
let roleKinds = _.get(this.ngRedux.getState(), 'auth.user.Role', [])
.filter(roleName => roles.indexOf(roleName) != -1);
...