Sinon 介绍
Standalone test spies,stubs and mocks for JavaScript. Works with any unit testing framework.
npm
npm install sinon
The following function takes a function as its argument and returns a new function. You can call the resulting function as many times as you want,but the original function will only be called once:?
function once(fn) {
var returnValue,called = false;
return function () {
if (!called) {
called = true;
returnValue = fn.apply(this,arguments);
}
return returnValue;
};
}
?
网站地址 : http://sinonjs.org/
GitHub: https://github.com/sinonjs/sinon
网站描述: 一套面向js的单元测试辅助库
Sinon官方网站
官方网站: http://sinonjs.org/
如果觉得 网站内容还不错,欢迎将 网站 推荐给程序员好友。
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did177329