Chai.should()使摩卡爆炸

seb*_*lon 1 bdd mocha.js node.js chai

我尝试使用Chai应该使用样式断言,但以下声明使Mocha爆炸.这是我完整的Require块:

/**                                         
 * Module dependencies.                     
 */                                         
var mongoose = require('mongoose'),         
  User = mongoose.model('User'),            
  moment = require('moment'),               
  SSEvent = mongoose.model('Event'),        
  chai = require('chai');                   

chai.use(require('chai-datetime'));         
var should = chai.should();                   
Run Code Online (Sandbox Code Playgroud)

错误信息:

Running "mochaTest:src" (mochaTest) task
>> Mocha exploded!
>> TypeError: chai.should is not a function
>>     at Object.<anonymous> (/Users/sebastianweikart/Desktop/dev/conftool-nga-mean/modules/events/tests/server/events.server.model.tests.js:13:19)
>>     at Module._compile (module.js:413:34)
>>     at Object.Module._extensions..js (module.js:422:10)
>>     at Module.load (module.js:357:32)
>>     at Function.Module._load (module.js:314:12)
>>     at Module.require (module.js:367:17)
>>     at require (internal/module.js:16:19)
>>     at /Users/sebastianweikart/Desktop/dev/conftool-nga-mean/node_modules/mocha/lib/mocha.js:219:27
Run Code Online (Sandbox Code Playgroud)

可能是什么问题?我用 "chai": "^3.5.0""mocha": "~2.4.5"这应该是最新的稳定版本..

更新:

我现在添加了以下简单的剥离测试 - 它仍然会爆炸:

'use strict';

/**
 * Module dependencies.
 */
var chai = require('chai');
var should = chai.should();



/**
 * Unit tests
 */
describe('Chai Should Test', function () {

  describe('Chai Should() should work', function () {
    it('Chai Should() must work', function (done) {
      var spartacus = 'spartacus';
      should.exist(spartacus);
      done();
    });

  });
});



Running "mochaTest:src" (mochaTest) task
>> Mocha exploded!
>> TypeError: chai.should is not a function
>>     at Object.<anonymous> (/Users/sebastianweikart/Desktop/dev/conftool-nga-mean/modules/events/tests/server/chai.should.test.js:7:19)
Run Code Online (Sandbox Code Playgroud)

Asi*_*eed 5

确保在项目中卸载了should.js. 当should.js和chai.should一起使用时会发生冲突