我是节点上的sinon的新手,我只是在设置以下内容时得到了一个loooong错误+堆栈:
npm install expect --save-dev
npm install sinon --save-dev
这是我的测试文件,它只是一个mocha 4.0.1骨架,位于test / test1.js下:
var expect = require('expect')
var sinon = require('sinon')
describe('some test', function() {
it('should', function() {
})
})
然后,我只需运行mocha test / test1.js并获取:
/Users/user/dev/MyProj2/node_modules/just-extend/index.js:40
throw new Error('expected object, got ' + arg);
^
Error: expected object, got function FakeXMLHttpRequest(config) {
EventTargetHandler.call(this);
this.readyState = FakeXMLHttpRequest.UNSENT;
this.requestHeaders = {};
this.requestBody = null;
this.status = 0;
this.statusText = "";
this.upload = new EventTargetHandler();
this.responseType = "";
this.response = "";
this.logError = configureLogError(config);
if (sinonXhr.supportsTimeout) {
this.timeout = 0;
}
if (sinonXhr.supportsCORS) {
this.withCredentials = false;
}
if (typeof FakeXMLHttpRequest.onCreate === "function") {
FakeXMLHttpRequest.onCreate(this);
}
}
at extend (/Users/user/dev/MyProj2/node_modules/just-extend/index.js:40:13)
at Object.<anonymous> (/Users/user/dev/MyProj2/node_modules/nise/lib/fake-xhr/index.js:651:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/user/dev/MyProj2/node_modules/nise/lib/fake-server/index.js:3:15)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous>
..... this goes on
知道为什么吗?