【发布时间】:2017-08-28 19:39:25
【问题描述】:
使用 SinonJS 3 运行测试我面临以下问题
测试有什么问题?
var creator = (function() {
var createIfNotExists = function createIfNotExists() {
_doCreate();
};
var _doCreate = function _doCreate() {
console.log('_doCreate was called');
};
return {
createIfNotExists:createIfNotExists,
_doCreate:_doCreate
};
}());
var util = {
createIfNotExists:creator.createIfNotExists,
_doCreate:creator._doCreate
};
var spyRequester = sinon.spy(util, '_doCreate');
util.createIfNotExists();
console.log(spyRequester.callCount); // prints 0 (should be
线console.log(spyRequester.callCount);
应该打印 1 但它打印 0
【问题讨论】:
标签: javascript unit-testing testing sinon