错误:超时-在5000毫秒karma-jasmine

时间:2020-04-17 11:36:52

标签: angular unit-testing jasmine karma-jasmine

我在使用离子和角度的应用程序上工作,并且遇到了单元测试的问题:超时-异步回调未在5000毫秒内调用(由jasmine.DEFAULT_TIMEOUT_INTERVAL设置)

auth.service.ts

login(email: string, password: string) {
return this.http
  .post<AuthResponseData>(
    `https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=${
      environment.firebaseAPIKey
    }`,
    // tslint:disable-next-line: object-literal-shorthand
    { 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';
server.login('s@S.com', '987456').subscribe(
    good =>  {
    },
    errRes => {
       expect(errRes.error.error.message).toEqual(e);
       done();
    },
   );
   }, );
   });

0 个答案:

没有答案