Karma Testing in Gulp: TypeError: undefined is not a function

Karma Testing in Gulp: TypeError: undefined is not a function

我正在关注 gulp-karma github 页面以在 travis-ci 中进行我的业力测试 运行。

这是我的 Gulp 文件的一部分:

var gulp = require('gulp');
var Server = require('karma').server;


gulp.task('test', function (done) {
  Server.start({
      configFile: configFile,
      singleRun: true
    }, done);
});

这是我的一部分 package.json:

"karma": "0.12.0",
"karma-html2js-preprocessor": "0.1.0",
"karma-jade-preprocessor": "0.0.11",
"karma-jasmine": "0.1.5",
"karma-ng-html2js-preprocessor": "0.1.2",
"karma-phantomjs-launcher": "0.1.4",
"karma-requirejs": "0.2.1",
"karma-script-launcher": "0.1.0",
"karma-coffee-preprocessor": "0.2.1",

"brfs": "^1.2.0",
"browserify-shim": "~3.8.0",
"karma-browserify": "^3.0.0",

当我通过命令行 运行 业力测试时,它工作正常(一些测试通过,一些没有),但是当我 运行 gulp 测试时,我得到以下错误:

    [22:11:19] Error: 1
    at formatError (test-app/node_modules/gulp/bin/gulp.js:169:10)
    at Gulp.<anonymous> (test-app/node_modules/gulp/bin/gulp.js:195:15)
    at Gulp.emit (events.js:95:17)
    at Gulp.Orchestrator._emitTaskDone (test-app/node_modules/gulp/node_modules/orchestrator/index.js:264:8)
    at test-app/node_modules/gulp/node_modules/orchestrator/index.js:275:23
    at finish (test-app/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8)
    at cb (test-app/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:29:3)
    at Server.<anonymous> (test-app/node_modules/karma/lib/server.js:206:9)
    at Server.g (events.js:180:16)
    at Server.emit (events.js:117:20)
    at net.js:1277:10
    at process._tickCallback (node.js:448:13)

有人知道我做错了什么吗?

最后,我不得不更新到更新的版本,不仅是 karma 库,还有 Gulp(更新 Gulp 从 3.8.1 到 3.9.0,因为只更新 karma正在生成另一个错误)。

有了这个配置,它又开始工作了:

"gulp": "~3.9.0",
"karma": "~0.13.3",
"karma-browserify": "^3.0.0",
"karma-coffee-preprocessor": "~0.3.0",
"karma-html2js-preprocessor": "~0.1.0",
"karma-jade-preprocessor": "0.0.11",
"karma-jasmine": "^0.3.6",
"karma-ng-html2js-preprocessor": "^0.1.2",
"karma-phantomjs-launcher": "~0.2.0",
"karma-requirejs": "~0.2.2",
"karma-script-launcher": "~0.1.0",
"karma-spec-reporter": "0.0.20",

"brfs": "^1.2.0",
"browserify-shim": "~3.8.0",
"karma-browserify": "^3.0.0",

npm uninstall gulp-karma

帮我修好了