[英]How test the method property in Jest/Jasmine unit testing
I need to test the property of the method in jest.我需要开玩笑地测试方法的属性。 My test is passing but test coverage is not increasing.
我的测试通过了,但测试覆盖率没有增加。
How test the property of methods?如何测试方法的属性?
component.ts组件.ts
onClickExpanding() {
this.ownerName = this.getControl();
this.quest.parent.children.forEach(c=> c.Grp = false);
this.quest.Grp = true;
}
TestCase测试用例
it('onClickExpandingtest all property', () => {
copoment.quest.Grp= true;
expect(component.onClickExpanding).toBeTruthy();
});
Right now you are just checking if the method exists - that is why test coverage is not increasing.现在您只是在检查该方法是否存在——这就是测试覆盖率没有增加的原因。 If you are setting private component properties you can use the following syntax: expect(copoment['ownerName ']).toBe(whatever).
如果要设置私有组件属性,可以使用以下语法:expect(copoment['ownerName ']).toBe(whatever)。 If the property is public you can just access it via component.property..
如果该属性是公开的,您可以通过 component.property.. 访问它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.