能够在同一方法上设置多个间谍

时间:2018-03-13 10:22:57

标签: javascript unit-testing promise jasmine spyon

我们正在尝试使用Jasmine进行单元测试,以隔离我们需要测试的方法或组件,并了解它在各种情况下的行为。



return Promise.resolve(referenceObject()) //afraid this might execute out of order so force it inside promise chain.
           .then(() => this._apiClient.postRequest('putquestions', requestParametersPutSamples, questionInfo))
           .then(() => this._apiClient.postRequest('putitems', requestParametersPutNewSamples, { item: itemInfo }))
           .then((res: Array<any>) => this.expectEachResponseToBeOk(res));
   }
   
   
&#13;
&#13;
&#13;

我们正在使用spyOn作为现有方法,如上面的代码所示。 我们已将其强制转换为承诺链,因为这可能会无序执行。

关于我们如何监视同一个被调用两次但参数不同的方法的任何想法?

感谢。

0 个答案:

没有答案