这是我的带有 ActivatedRoute 的构造函数
constructor(private route: ActivatedRoute) {
this.claimId = +route.snapshot.params["claimId"];
}
我试图以这种方式在测试中模拟这个 ActivateRoute:
beforeEach((() => {
TestBed.configureTestingModule({
declarations: [TransactionSummaryComponent],
providers: [{
provide: useClass: MockClaim
}, {
provide: ActivatedRoute, useValue: {
params: Observable.of({ claimId: 1 })
}
}]
});
但是在构建测试时我收到一个错误:TypeError: Cannot read property 'params' of undefined