mocha.globals是“未定义的”

时间:2012-08-14 21:55:40

标签: javascript jquery mocha

尝试在浏览器中使用Mochaversion 1.3.2)时,the given example沿the expected way尝试在given example link中指定可接受的全局变量时出现以下异常(即类似mocha.globals(['amplify', '_'])):

Uncaught TypeError: Object function Mocha(options) {
  options = options || {};
  this.files = [];
  this.options = options;
  this.grep(options.grep);
  this.suite = new exports.Suite('', new exports.Context);
  this.ui(options.ui);
  this.reporter(options.reporter);
  if (options.timeout) this.suite.timeout(options.timeout);
} has no method 'globals' 

这在Chrome 21.0.1180中展示。

有人可以通过转到{{3}}并在浏览器控制台中运行mocha.globals(['123'])来重现这一点。

我希望mocha.globals可以像链接的示例所示那样工作,或者有一些关于替代方案的文档,但我找不到。

1 个答案:

答案 0 :(得分:1)

这是visionmedia / mocha GitHub上的issue #42。解决方案是,在Coffeescript中:

mocha.setup
  ui: 'bdd'
  globals: [ 'jade' ]