I just update from Angular 8 to Angular 9 and I have some problems that I don't really understand. I saw some few posts who looks similar to my problem but doesn't help me to solve anything (maybe because of me and not the solution given by others)
So, the problem is when I launch ng test I have this error:
error TS2339: Property 'payload' does not exist on type 'Action'.
The problem is on the spy.calls.allArgs()[1][0].payload.user. It's like the link between setUser and spy.calls.allArgs doesn't exist any more.
login.service.spec.ts
it('should get token', () => {
const store = TestBed.inject(Store);
const spy = spyOn(store, 'dispatch').and.callThrough();
service.getToken('root', '', 'MY_DATABASE').subscribe(() => {
expect(spy).toHaveBeenCalled();
spy.calls.allArgs()[1][0]);
const user: User = spy.calls.allArgs()[1][0].payload.user;
expect(user.database).toBe('MY_DATABASE');
});
});
login.actions.ts
export class SetUser implements Action {
readonly type = LOGIN_ACTION_TYPES.SET_USER;
constructor(public payload: SetUserActionInterface) {}
}
interface SetUserActionInterface {
user: User;
}
What's the problem in my code?