I have this Angular web application I want to run e2e tests on a mocked out REST API. I can stub out my network requests to my REST API easy enough, but the authentication is using a third-party provider (Cognito using Amplify).
Now I want to stub out the Angular service that wraps the authentication.
In Angular I have
@Injectable({
providedIn: 'root'
})
export class AuthenticationService {
some methods
isSignedIn(): Observable<boolean> {
...
}
}
I want to stub the isSignedIn()
-method. My first attempt looks something like this:
import {AuthenticationService} from "../../src/app/authentication.service";
import {BehaviorSubject} from "rxjs";
context('albums', () => {
it('get albums', () => {
cy.stub(AuthenticationService,'isSignedIn').returns(new BehaviorSubject(true));
}
}
Cypress/Chrome then complains it cannot find AuthenticationService on that location. How do I solve this?