title: How to test toPromise in Angular 9
body: <p>I am trying to write unit test for the following function</p>
  <pre><code>    public loadValues(): Promise&lt;any&gt; {
  
        return this._http.get(this.url)
           .toPromise()
           .then((values: any) =&gt; {
              this.values = values;
           })
       }
  </code></pre>
  <p>This function is called by the APP_INITIALIZER and thats the reason it is returning a promise instead of observable. I did not find any article to test toPromise, any help will be appreciated.</p>
  <p>I have the following test written for it</p>
  <pre><code>it('should return app values', async () =&gt; {
      const mockValues = {test: 123};
      spyOn(httpClient, 'get').and.returnValue(of(mockValues)).and.callThrough();
      await service.loadValues();
      expect(service.values).toEqual(mockValues);
  
      const req = httpMock.expectOne(TEST_URL);
      expect(req.request.method).toBe('GET');
  });
  </code></pre>