I'm quite new to Unit testing so bear with me
I'm trying to unit test a service that is used to log the user with Amplify in an Angular application.
Right now in the spec file I'm doing:
 beforeEach(async () => {
        TestBed.configureTestingModule({
            imports: [
                HttpClientTestingModule,
            ],
            providers: [
                MyService, Amplify
            ]
        }
      myService = TestBed.get(MyService)
      amplify = TestBed.get(Amplify)
    })
   it('should login', async () => {
      const objToBeReturned = { signInUserSession: { idToken: { jwtToken: 'tokenValue' } } }
      spyOn(Amplify.Auth, 'signIn').and.returnValue(objToBeReturned)
      await myService.login('username', 'password')
   })
While in MyService :
  public async login(username: string, password: string) {
    const authUser = await Amplify.Auth.signIn(username.toLowerCase(), password)
    if (authUser.signInUserSession != null) {
      const idToken = authUser.signInUserSession.idToken.jwtToken
      return this.patientLogin(idToken)
    }
   }
  private async patientLogin(idToken?: string): Promise<boolean> {
    await this.sendRequest<LoginResponse>(url, data).pipe(
      tap(response => {
        if (!isLoginResponse(response)) {
          throw throwErr({ code: 'Generic' })
        }
        this.token = response.token
      })
    ).toPromise()
    return true
  }
This gives me the error Async function did not complete within 5000ms
I'm pretty sure it depends on the way I'm mocking Amplify
How do i properly mock it?
 
     
    