title: Solve "An error was thrown in afterAll with is not iterable" in Angular test with Karma/Jasmine
body: <p>I'm getting this error with Angular testing running Karma:</p>
  <pre><code>  An error was thrown in afterAll
    TypeError: data.data is not iterable
  </code></pre>
  <p>This is my service that I want to test:</p>
  <pre><code>getData(): Observable&lt;RealDataModel&gt; {
      return this.http.get&lt;DataResponseModel&gt;('my-url')
        .pipe(
          map((data: DataResponseModel) =&gt; (
            { books: [...data.data] }
          ))
        );
  }
  </code></pre>
  <p>My get return an Object like that (DataResponseModel):</p>
  <pre><code>{
      data: [{...}]
  }
  </code></pre>
  <p>But I need to map it in an object like that</p>
  <pre><code>export class RealDataModel {
    books: [{...}];
    // Other info that I put using .map
  }
  </code></pre>
  <p>This is my test where I have added verify and resetTestingModule after googling hoping to solve the issue but it's seems not working:</p>
  <pre><code>describe('DataService', () =&gt; {
    let service: DataService;
    let httpTestingController: HttpTestingController;
  
    beforeEach(() =&gt; {
      TestBed.configureTestingModule({
        imports: [
          HttpClientTestingModule
        ]
      });
      service = TestBed.inject(DataService);
      httpTestingController = TestBed.inject(HttpTestingController);
    });
  
    afterEach(() =&gt; {
      httpTestingController.verify();
    });
  
    afterAll(() =&gt; {
      TestBed.resetTestingModule();
    });
  
    it('should be created', () =&gt; {
      expect(service).toBeTruthy();
    });
  
    it('should be have a call /my-url', () =&gt; {
      const mockResponse: RealDataModel = {
        books: [{...}]
      };
  
      service.getData().subscribe(data =&gt; {
        expect(data).toEqual(mockResponse);
      });
  
      const testReq = httpTestingController.expectOne('/my-url');
  
      expect(testReq.request.method).toEqual('GET');
      testReq.flush(mockResponse);
    });
  
  });
  </code></pre>