Mocha接口:未捕获的ReferenceError:`describe`未定义

时间:2015-10-07 18:10:48

标签: mocha karma-runner karma-mocha

我正在使用Gulp与mocha / sinon / chai和jquery运行业力

我的karma.conf.js有:

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jquery-2.1.0', 'mocha'],

// Plugin specific config
client: {
  mocha: {
    reporter: 'spec',
    ui: 'tdd'
  }
}

安装的节点模块是

"devDependencies": {
    "chai": "",
    "gulp": "",
    "gulp-jslint": "",
    "gulp-notify": "",
    "gulp-phpunit": "",
    "gulp-util": "",
    "karma": "",
    "karma-chai": "",
    "karma-chrome-launcher": "",
    "karma-cli": "",
    "karma-firefox-launcher": "",
    "karma-ie-launcher": "",
    "karma-jquery": "",
    "karma-mocha": "",
    "karma-opera-launcher": "",
    "karma-safari-launcher": "",
    "karma-sinon": "",
    "mocha": "",
    "sinon": "*"
}

但是当我跑到业力时我得到了这个错误

"C:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.5\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" C:\path\to\my\project\node_modules\gulp\bin\gulp.js --color --gulpfile c:\path\to\my\project\Gulpfile.js karma:unit
[10:58:05] Using gulpfile c:\path\to\my\project\Gulpfile.js
[10:58:05] Starting 'karma:unit'...
[2015-10-07 10:58:05.142] [DEBUG] config - Loading config c:\path\to\my\project\karma.conf.js
07 10 2015 10:58:05.236:WARN [karma]: No captured browser, open http://localhost:9876/
07 10 2015 10:58:05.245:INFO [karma]: Karma v0.13.10 server started at http://localhost:9876/
07 10 2015 10:58:05.249:INFO [launcher]: Starting browser Chrome
07 10 2015 10:58:06.262:INFO [Chrome 45.0.2454 (Windows 7 0.0.0)]: Connected on socket 3C6LlqYiiMMpHEnaAAAA with id 29319610
Chrome 45.0.2454 (Windows 7 0.0.0) ERROR
Uncaught ReferenceError: describe is not defined
at c:/path/to/my/project/test/test.class.view.js:7

我已经尝试过全局安装karma-mocha和mocha。 我尝试将karma-mocha作为karma.conf.js上的插件

1 个答案:

答案 0 :(得分:10)

我正在使用' tdd'用于摩卡配置。它应该是' bdd'。

// Plugin specific config
client: {
  mocha: {
    reporter: 'spec',
    ui: 'bdd'
  }
}

'描述'如果设置是' bdd'不是' tdd'