mardi 29 décembre 2020

Angular Unit testing: Testing http with real APIs

I am writing unit tests in angular CLI using karma. I want to test http calls with real API and not using mocks. Because API models are changing frequently and I'm looking for a way to be sure about my endpoint responses. Is there any solution or sample code?

Here is on my services that I want to test with real API:

  getCodeRequest(phone: string) {

    let params = new HttpParams();
    params = params.append('phone', String(phone));

    return this.http.get('/auth/request', { params });
  }

I will appreciate any tip or point.

Aucun commentaire:

Enregistrer un commentaire