0
我有一个我试图测试的TypeScript(最终测试实际的JavaScript)方法。这很简单:茉莉间谍对新对象?
private static myMethod(foo: IFoo): void {
let anInterestingThing = new InterestingThing();
foo.bar = anInterestingThing.getSomethingCool();
}
我想测试getSomethingCool
已经调用了正常,我只想做一个简单的spyOn
,但我无法弄清楚如何将新anInterestingThing
对象上窥视。什么是最好的方法来做到这一点?
这是不可能的。你无法知道当你新建对象时引用的内容。据我所知,这是简单的无法测试的代码。用工厂函数重构依赖注入。 –