angular 8中函数属性的代码覆盖问题

问题描述 投票:1回答:1

Code Coverage error with Angular 8 project

谁能建议Jasmine的单元测试用例来解决这个代码覆盖率问题?

javascript angular typescript jasmine karma-jasmine
1个回答
1
投票
  1. 你需要创建一个 describe 块,如下所示。

    it('should create with necessary variables', () => {
      expect(component).toBeTruthy();
      component.Items[0].getInfo();
      expect(component.isIndian).toBeTruthy();
      // and so on....
    });
    
  2. 你正在设置 this.isIndian 作为 false 在第19行,然后 true 在第21行。请据此更正。

如果你想探索最佳实践,你可以看一下文章集。在本文.

© www.soinside.com 2019 - 2024. All rights reserved.