First of all, as @Aviad P. pointed out, the forkJoin method does not return an array of observable observables ... it returns an array of the result of each observable in forkJoin and the result of these observables is not an instance of Observables.
In addition, you are not mocking the getChart () method, while you are mocking the layout backend for every HTTP call , but not for the getChar () method. The array must be length === 2, because not this.chartId and this.comicsId are present ...
So, I would say that the returned structure is something like this, so response [0] is an array:
response = [[Observable, Observable], [Observable, Observable]]
It is said that this expectation will never be true, because no array will be equal to the newly created array:
expect(response).toEqual([Observable, Observable])
Changing everything that should solve your problems. In addition, if your Observables returns and an Observable instance, your code: "body: [Observable, Observable]" does not return Observables instances, it returns the Observable definition function, this will not be the correct layout, although the test will pass.
This will be a test case that fails for:
const mockResponse = {isMockResponse: true}; it('should get ObservableArray async', async(inject([DataService], (dataService: DataService) => { mockBackend.connections.subscribe( (connection: MockConnection) => { connection.mockRespond(new Response( new ResponseOptions({ body: {...mockResponse} } ))); }); dataService.getChar().subscribe( (response) => { expect(response.length).toBe(2); expect(response[0].isMockResponse).toBe(true); <<< Is this expect really necessary? expect(response[1].isMockResponse).toBe(true); <<< Is this expect really necessary? }); })));
Said that, just expect to check your use case:
expect(response.length).toBe(2);
Others are not needed ... so you are not checking the data you are mocking, you want to test the number of calls that were made due to the value of this variables. chartId and this.comicsIs.
Hope this helps.