我在Karma下运行单元测试,并且使用sinon-chai库。
Mac上一切都很好,但现在我已经转到Windows,出现了以下错误:
C:\Users\mchambe4\dev\simple\client>node ./node_modules/gulp/bin/gulp.js unit-tests-dev
[16:29:31] Using gulpfile ~\dev\simple\client\gulpfile.js
[16:29:31] Starting 'unit-tests-dev'...
[16:29:31] Starting Karma server...
WARN [karma]: Port 9876 in use
INFO [karma]: Karma v0.12.37 server started at http://localhost:9877/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.8 (Windows 7 0.0.0)]: Connected on socket fMujwCqRPdmidI3BtCYV with id 16821903
PhantomJS 1.9.8 (Windows 7 0.0.0) ERROR
ReferenceError: Can't find variable: chai
at C:/Users/mchambe4/dev/simple/client/node_modules/karma-sinon-chai/node_modules/sinon-chai/lib/sinon-chai.js:17来自那个档案
if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
// NodeJS
module.exports = sinonChai; // <---- should go in here
} else if (typeof define === "function" && define.amd) {
// AMD
define(function () {
return sinonChai;
});
} else {
// Other environment (usually <script> tag): plug in to global chai instance directly.
chai.use(sinonChai); // <---- actually ends up here
}我希望第一行上的条件返回true,因为我在Node中运行,但是由于某种原因,没有定义'require‘或module,所以它在上面指明的点结束了。
有什么想法吗?
发布于 2015-07-17 16:17:50
降低业力一个github问题已经提交,我想这将很快得到解决。https://github.com/kmees/karma-sinon-chai/issues/21
npm install karma-sinon-chai@0.3.2 --save-devhttps://stackoverflow.com/questions/31469889
复制相似问题