angular 8 中函数属性的代码覆盖率问题
Code Coverage issue in angular 8 with function properties
谁能建议 Jasmine 的单元测试用例来解决这个代码覆盖问题?
您需要创建一个 describe
块,如下所示:
it('should create with necessary variables', () => {
expect(component).toBeTruthy();
component.Items[0].getInfo();
expect(component.isIndian).toBeTruthy();
// and so on....
});
您在第 19 行将 this.isIndian
设置为 false
,然后在第 21 行将 true
设置为 true
。请相应地更正。
如果您想探索最佳实践,可以查看文章集in this article。
谁能建议 Jasmine 的单元测试用例来解决这个代码覆盖问题?
您需要创建一个
describe
块,如下所示:it('should create with necessary variables', () => { expect(component).toBeTruthy(); component.Items[0].getInfo(); expect(component.isIndian).toBeTruthy(); // and so on.... });
您在第 19 行将
this.isIndian
设置为false
,然后在第 21 行将true
设置为true
。请相应地更正。
如果您想探索最佳实践,可以查看文章集in this article。