2
ルーティングを使用するangular2コンポーネントをユニットテストしようとしています。私が持っている:Jasmine route spy - undefinedはオブジェクトではありません( 'navigate.calls.mostRecent()。args'を評価しています)
class MockRouter {
}
class MockAuth {
isLoggedIn(){
return false;
}
}
describe('Home',() => {
beforeEach(() => TestBed.configureTestingModule({
providers: [
BaseRequestOptions,
{ provide: Router, useClass: MockRouter },
HomeComponent,
{ provide: AuthenticationService, useClass: MockAuth }
]
}));
it('should navigate to login', inject([HomeComponent], (home: HomeComponent) => {
let navigate = jasmine.createSpy('navigate');
expect(navigate.calls.mostRecent().args[0]).toEqual(['/login']);
}));
});
が、私はエラーを取得しています:
TypeError: undefined is not an object (evaluating 'navigate.calls.mostRecent().args') in config/spec-bundle.js (line 41757)
私はジャスミンのスパイが正しいアプローチであるが、私は私が間違っているの - どのように何かを見逃していると思いますか?