Hellow, guys.
I’m trying to finish the spec of component in my project, and I’m having the trouble with ‘describe’ in my spec file.
The test is crashing in this line:
ngOnInit() {
//error here 'subscribe is not a function'
this.appComponent.currentToken.subscribe(tokenRecebido => this.tokenRecebidoTemp = tokenRecebido);
}
- Some observations:
- The ‘appComponent’ above is mocked with ‘spyOn’ of jasmine:
let appComponentMock: any = {
currentToken: tokenMock
};
beforeEach(() => {
fixture = TestBed.createComponent(ListMenuSheetComponent);
component = fixture.componentInstance;
component.appComponent = appComponentMock;
//and.returnValue({ subscribe: () => {} });
//component.appComponent.currentToken.subscribe(data=>expect(data).toEqual(undefined))
//component.currentToken = new TokenEleicao();
fixture.detectChanges();
});
But when the spec run, I’m getting the error ‘subscribe is not a function’…
Please, help.