I have unit tests running under Karma, and am using the sinon-chai library.
Everything was working fine on Mac, but now I have moved to Windows the following error is occuring:
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
From that file:
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 }
I would expect the condition on the first line to return true
because I am running in Node, but for some reason neither 'require' or module
are defined, so it ends up at the point indicated above.
Any ideas?