Code Coverage issue in angular 8 with function properties

Viewed 262

Code Coverage error with Angular 8 project

Can anyone suggest unit test case for Jasmine to resolve this code coverage issue?

1 Answers
  1. You need to create a describe block as below:

    it('should create with necessary variables', () => {
      expect(component).toBeTruthy();
      component.Items[0].getInfo();
      expect(component.isIndian).toBeTruthy();
      // and so on....
    });
    
  2. You are setting this.isIndian as false at line 19 and then true at line 21. Please correct it accordingly.

In case you want to explore best practices, you can take a look at collection of articles in this article.

Related