使用webpack构建,并使用sinon模拟超时,我收到此错误。
未定义”不是对象(评估“modules [moduleId] .call
代码如下。
var sinon = require('sinon');
describe('sinon stubbing', function () {
var clock;
before(function () {
clock = sinon.useFakeTimers();
});
it('should wait for timeout and test', function (done) {
//code with window.timeout testing
clock.tick(1000);
done();
});
after(function () {
clock.restore();
});
});
我用过
npm install --save-dev mocha chai sinon
安装依赖项。我也尝试过手动将sinon版本添加到package.json,但是没有运气。
最佳答案
问题出在我的package.json上。
我需要像这样指定sinon依赖性。
"sinon": "git+https://github.com/sinonjs/sinon.git"
已报告此问题here
关于angularjs - Webpack构建中的sinon模拟超时错误- 'undefined'不是对象(评估 'modules[moduleId].call',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34869017/