Reputation: 317
I am a beginner for Angular, recently I started working on Angular. I have written some unit testing code, as follows.
it('fetch data should be correct',
inject(
[HttpTestingController, Service2Service],
(
httpMock: HttpTestingController,
dataService: Service2Service
) =>{
dataService.getData().subscribe((event: HttpEvent<any>) => {
console.info("HttpEventType.Response",HttpEventType.Response);
switch (event.type) {
case HttpEventType.Response:{
console.log("body",event.body);
expect(event.body.length).toEqual(110);
}
}
});
}
)
);
I am trying to print using console.log but it not printing on console. Kindly suggest another way to print log.
Thanks in advance.
Upvotes: 6
Views: 11524
Reputation: 86730
Try by putting captureConsole
to property client in karma.conf.js
:
client: {
captureConsole: true,
mocha: {
bail: true
}
}
For more info refer -
Upvotes: 7