"Cannot read property 'then' of undefined" on Jasmine Test

Viewed 98

I have a Jasmine test that is failing with the error:

TypeError: Cannot read property 'then' of undefined

This is the code I have:

logout(isSessionExpired: boolean = false): void {
    this.sessionStorageService.removeByKeyPrefix(SessionStorageService.keys.reportPrefix);
    this.clientService.logout();
    this.setAuthenticationState();
    this.stopImmediateMessageTimer();
    this.stopSessionCheckTimer();
    this.breadcrumbString = "";
    this.areShortcutsLoaded = false;
    this.sessionService.endSession(isSessionExpired)
        .then(() => this.cookieService.deleteLoginCookies())
        .then(() => this.$state.go("login", { isLogout: true }, { inherit: false }));
}

I assume that .then is undefined but I have not been able to resolve this so far. Would anyone be willing to give some advice on this and the best way to resolve it?

0 Answers
Related