1

我正在使用 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 上的插件

4

1 回答 1

10

我在 mocha 配置中使用了 'tdd'。它应该是'bdd'。

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

如果设置是 'bdd' 而不是 'tdd','describe' 会暴露

于 2015-10-07T22:52:25.107 回答