0
我想为私有变量编写单元测试。但茉莉花不允许我使用它。有人能解释我该怎么做吗?使用私有变量进行角单元测试
export class TestComponent implements OnInit {
private resolve;
public testPrivate() {
this.resolve(false);
}
}
it(
'should test private variable',() => {
component.testPrivate();
expect(component.resolve).toEqual(false);
});
或'(component as any).resolve' – yurzui
TypeError:this.resolve不是函数。尝试第一种方法时出现此错误。 – Ish
当然不是,:)你是什么意思? – Milad