Karma / Chrome的警告和错误

时间:2014-10-30 19:23:33

标签: javascript angularjs karma-runner karma-jasmine

现在只需使用“AngularJS Up and Running”这本书即可学习angularjs。来自O' Reilly .. 进入Karma&amp ;;的单元测试章节Jasmine,但无法使其工作

编辑:将logLevel更改为config.LOG_DEBUG现在可以正确匹配文件模式。但我仍然拥有最终的适配器'最后的错误。

运行'业力开始'命令给我以下内容:

DEBUG [plugin]: Loading karma-* from /Work/[lab]/angularjs-up-and-running/chapter3/node_modules
DEBUG [plugin]: Loading plugin /Work/[lab]/angularjs-up-and-running/chapter3/node_modules/karma-chrome-launcher.
DEBUG [plugin]: Loading plugin /Work/[lab]/angularjs-up-and-running/chapter3/node_modules/karma-jasmine.
INFO [karma]: Karma v0.12.16 server started at http://localhost:8080/
INFO [launcher]: Starting browser Chrome
DEBUG [temp-dir]: Creating temp dir at /var/folders/dw/qt56vk_s4cz5h6hg8qddvmrm0000gn/T/karma-24748311
DEBUG [launcher]: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome --user-data-dir=/var/folders/dw/qt56vk_s4cz5h6hg8qddvmrm0000gn/T/karma-24748311 --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate http://localhost:8080/?id=24748311
WARN [watcher]: Pattern "/Work/[lab]/angularjs-up-and-running/chapter3/node_modules/karma-jasmine/lib/jasmine.js" does not match any file.
WARN [watcher]: Pattern "/Work/[lab]/angularjs-up-and-running/chapter3/angular-mocks.js" does not match any file.
WARN [watcher]: Pattern "/Work/[lab]/angularjs-up-and-running/chapter3/node_modules/karma-jasmine/lib/adapter.js" does not match any file.
WARN [watcher]: Pattern "/Work/[lab]/angularjs-up-and-running/chapter3/angular.min.js" does not match any file.
WARN [watcher]: Pattern "/Work/[lab]/angularjs-up-and-running/chapter3/simpleSpec.js" does not match any file.
WARN [watcher]: Pattern "/Work/[lab]/angularjs-up-and-running/chapter3/controller.js" does not match any file.
WARN [watcher]: Pattern "/Work/[lab]/angularjs-up-and-running/chapter3/controllerSpec.js" does not match any file.
DEBUG [watcher]: Resolved files:

DEBUG [watcher]: Watching "/Work/[lab]/angularjs-up-and-running/chapter3/angular.min.js"
DEBUG [watcher]: Watching "/Work/[lab]/angularjs-up-and-running/chapter3/angular-mocks.js"
DEBUG [watcher]: Watching "/Work/[lab]/angularjs-up-and-running/chapter3/controller.js"
DEBUG [watcher]: Watching "/Work/[lab]/angularjs-up-and-running/chapter3/simpleSpec.js"
DEBUG [watcher]: Watching "/Work/[lab]/angularjs-up-and-running/chapter3/controllerSpec.js"
DEBUG [web-server]: serving: /Work/[lab]/angularjs-up-and-running/chapter3/node_modules/karma/static/client.html
DEBUG [web-server]: serving: /Work/[lab]/angularjs-up-and-running/chapter3/node_modules/karma/static/karma.js
DEBUG [web-server]: upgrade /socket.io/1/websocket/YVK_k4vczJIuLIdg5a_f
DEBUG [karma]: A browser has connected on socket YVK_k4vczJIuLIdg5a_f
INFO [Chrome 38.0.2125 (Mac OS X 10.10.0)]: Connected on socket YVK_k4vczJIuLIdg5a_f with id 24748311
DEBUG [launcher]: Chrome (id 24748311) captured in 5.575 secs
DEBUG [karma]: All browsers are ready, executing
DEBUG [web-server]: serving: /Work/[lab]/angularjs-up-and-running/chapter3/node_modules/karma/static/context.html
Chrome 38.0.2125 (Mac OS X 10.10.0) ERROR
  You need to include some adapter that implements __karma__.start method!

首先,它有警告查找文件,但所有这些文件确实存在于该位置。

我的karma.conf.js文件如下所示:

module.exports = function(config) {
  config.set({
    // base path, that will be used to resolve files and exclude
    basePath: '',

    // testing framework to use (jasmine/mocha/qunit/...)
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'angular.min.js',
      'angular-mocks.js',
      'controller.js',
      'simpleSpec.js',
      'controllerSpec.js'
    ],

    // list of files / patterns to exclude
    exclude: [],

    // web server port
    port: 8080,

    // level of logging
    // possible values: LOG_DISABLE || LOG_ERROR ||
    //                  LOG_WARN || LOG_INFO || LOG_DEBUG
    logLevel: config.LOG_DEBUG,


    // enable / disable watching file and executing tests
    // whenever any file changes
    autoWatch: true,

    // Start these browsers, currently available:
    // - Chrome
    // - ChromeCanary
    // - Firefox
    // - Opera
    // - Safari (only Mac)
    // - PhantomJS
    // - IE (only Windows)
    browsers: ['Chrome'],


    // Continuous Integration mode
    // if true, it capture browsers, run tests and exit
    singleRun: false
  });
};

karma安装在我的项目文件夹中(karma.conf.js所在的位置)

我真的不知道出了什么问题,我无法找到联系本书作者的方法。谢谢!

1 个答案:

答案 0 :(得分:2)

我面对同样的问题,我的思绪即将爆发。我无法在任何地方找到任何东西,所有配置都没问题,似乎没有任何错误。你的问题是我能找到的最接近的东西。

我意识到两者,你的项目文件路径和我的包含方括号(... / [lab] / ...在你的)中,它可能是原因。众所周知,特殊的角色有时会很麻烦。

我从文件路径中删除了方括号,所有测试都完美无缺。

如果注意Debug行,则jasmine.js和adapter.js未解析。

我希望这可能有所帮助。