title: How to print debug message in Angular test?
body: <p><strong>Edit:</strong> this question is totally wrong because Angular DO NOT call http request in unit test. You cannot print the truly response from request. The unit test &quot;fake&quot; the response of the request then put into place. If you come into same question as I do, please read documentation on Angular unit test again.</p>
  <hr />
  <p>I want to <code>console.log(&quot;my text&quot;)</code> or something similar in unittest.</p>
  <p><strong>the-cat-api.service.ts</strong></p>
  <pre><code>import { Injectable } from '@angular/core';
  import {HttpClient} from '@angular/common/http';
  
  @Injectable({
    providedIn: 'root'
  })
  export class TheCatApiService {
    private catApi=&quot;05f72f39-87d9-4166-b4f1-6dfb55db1744&quot;
    private REST_API = &quot;https://api.thecatapi.com/v1/images/search?api_key=&quot;
    constructor(private httpClient: HttpClient) { }
  
    getCat(){
      return this.httpClient.get(this.REST_API + this.catApi);
    }
    
  }
  </code></pre>
  <p><strong>the-cat-api.service.spec.ts</strong></p>
  <pre><code>import { TestBed } from '@angular/core/testing';
  import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
  import {HttpClientModule} from '@angular/common/http';
  import { TheCatApiService } from './the-cat-api.service';
  
  describe('TheCatApiService', () =&gt; {
    let service: TheCatApiService;
  
    beforeEach(() =&gt; {
      TestBed.configureTestingModule({
        imports: [HttpClientTestingModule], 
        providers: [TheCatApiService]
      });
      service = TestBed.inject(TheCatApiService);
    });
  
    it('should be created', () =&gt; {
      expect(service).toBeTruthy();
    });
  
    it('should return cat', () =&gt;{
      service.getCat().subscribe((data) =&gt; {
        console.log(&quot;test the cat api &quot;)
        console.log(data)
      })
    })
  });
  </code></pre>
  <p>When I run <code>ng test</code> it show</p>
  <pre><code>➜  learn-service git:(master) ✗ ng test                           
  10% building 2/2 modules 0 active24 07 2020 13:58:33.558:WARN [karma]: No captured browser, open http://localhost:9876/
  24 07 2020 13:58:33.562:INFO [karma-server]: Karma v5.0.9 server started at http://0.0.0.0:9876/
  24 07 2020 13:58:33.563:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
  24 07 2020 13:58:33.567:INFO [launcher]: Starting browser Chrome
  24 07 2020 13:58:39.580:WARN [karma]: No captured browser, open http://localhost:9876/
  24 07 2020 13:58:39.724:INFO [Chrome 84.0.4147.89 (Linux x86_64)]: Connected on socket MWHJE0_oK6DZDg3_AAAA with id 30651510
  WARN: 'Spec 'TheCatApiService should return cat' has no expectations.'
  Chrome 84.0.4147.89 (Linux x86_64): Executed 5 of 6 SUCCESS (0 secs / 0.276 secs)
  Chrome 84.0.4147.89 (Linux x86_64): Executed 6 of 6 SUCCESS (0.409 secs / 0.282 secs)
  </code></pre>
  <p>I check developer console of chrome (Karma test framework) and see no console log.</p>