Currently, I am working on developing an application with Ionic and Angular. However, I encountered a problem during unit testing where the return value is undefined, even though the app runs correctly.
In my code:
auth.service.ts
login(email: string, password: string) {
return this.http
.post<AuthResponseData>(
`https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=${
environment.firebaseAPIKey
}`,
{ email: email, password: password }
).pipe(tap(this.setUserData.bind(this)));}
auth.service.spec.ts
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { AuthService } from './auth.service';
let server: AuthService;
describe('AuthService', () => {
beforeEach(() => TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [AuthService]
}));
beforeEach(() => server = TestBed.get(AuthService));
it('fail ', done =>{
const e = 'INVALID_PASSWORD';
let result;
server.login('<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6a192a3944090507">[email protected]</a>', '987456').subscribe(
good => {
},
errRes => {
result = errRes.error.error.message;
}
);
expect(result).toEqual(e);
done();
});
});
I am looking for some guidance to resolve this issue =(