在执行gulp test-browser命令时,我收到了以下警告消息
WARN [reporter]: Can not load “mocha”,it is not registered!
Perhaps you are missing some plugin?
但如果我执行karma start命令它工作正常,它不会显示任何警告信息.
为什么我收到此警告消息?
我在这里错过了什么?
的package.json
{ ''' "dependencies": { "browser-sync": "^2.9.12","gulp": "^3.9.0","karma": "^0.13.15","karma-mocha": "^0.2.0","mocha": "^2.3.3" },"devDependencies": { "karma-phantomjs-launcher": "^0.2.1","phantomjs": "^1.9.18" } }
gulpfile.js
gulp.task('test-browser',function () { var config = { configFile: __dirname + '/karma.conf.js',singleRun: true,reporters: ['mocha'] }; var server = new Server(config); server.start(); });
karma.conf.js
module.exports = function (config) { config.set({ browsers: ['PhantomJS'],frameworks: ['mocha'],files: [ "bower_components/angular/angular.js","bower_components/chai/chai.js","app/**/*.js","test/*.spec.js" ] }); };
这里的问题是你没有在你的karma.conf.js插件中安装或添加karma-mocha-reporter.
原文链接:https://www.f2er.com/angularjs/140831.html如果你没有安装它.
npm install karma-mocha-reporter --save-dev
module.exports = function(config){ config.set({ plugins:['karma-mocha','karma-phantomjs-launcher','karma-mocha-reporter'],browsers:['PhantomJS'],frameworks:['mocha'],files:[ "bower_components/angular/angular.js","bower_components/angular-mocks/angular-mocks.js","test/*.js" ],colors: true,}) }
它应解决警告并使其正常工作.