2012-08-14 23 views
1

當試圖在瀏覽器中使用Mochaversion 1.3.2),沿the given example線,我想在the expected way到指定可接受的全局,當出現以下情況例外(即類似mocha.globals(['amplify', '_'])):mocha.globals是「不確定」

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中展出。

可以通過轉到given example link並在瀏覽器控制檯中運行mocha.globals(['123'])來重現此操作。

我期望mocha.globals工作正如鏈接的例子所示,或者有一些關於替代文件的文檔,但我沒有找到。

回答

1

這是關於visionmedia/mocha GitHub的issue #42。解決的辦法是,在CoffeeScript的:

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

跟進,在JS解決辦法是:mocha.setup({UI: 'BDD',全局:[ '玉']}) – 2012-11-09 17:23:53