Karma没有运行测试

时间:2013-08-21 20:15:56

标签: unit-testing angularjs karma-runner

我已经在我的应用程序上使用grunt运行业力,但由于某种原因,事情停止了工作。我通过重新安装更新了业力,这改变了很多,并更改了我的配置文件。我的所有文件都被添加和提供,但是它没有执行我的任何测试。

暂时(只是试图让事情再次运行),我使用命令karma start <pathtomyconfigfile>在grunt之外运行。使用LOG_DEBUG选项,我看到所有内容已添加并提供服务。

这是我的配置文件:

module.exports = function(config) {
config.set({

    // base path, that will be used to resolve files and exclude
    basePath: '',


    // frameworks to use
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser
    files: [
        '../build/angular/angular.js',
        '../build/angular/angular-mocks.js',
        '../build/angular/angular-resource.js',
        '../build/angular/angular-cookies.js',
        '../build/angular/angular-scenario.js',
        '../src/**/*.js',
        '../dist/tmp/**/*.js',
        '../vendor/angular-bootstrap/*.js',
        '../vendor/angular-ui-utils/modules/route/*.js',
        '../vendor/angular-ui-utils/modules/mask/*.js'
    ],


    // list of files to exclude
    exclude: [

    ],


    // test results reporter to use
    // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
    reporters: ['progress'],


    // web server port
    port: 9018,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.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'],//nothing so we can start it on our own


    // If browser does not capture in given timeout [ms], kill it
    captureTimeout: 60000,


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

我在这里不知所措,在不同的浏览器上运行,更改观看的文件,在旧的方式之间切换,将文件变量中的框架加载到框架变量...任何帮助将不胜感激。谢谢!

其他信息

似乎我的业力是错误的,除了错误之外没有任何其他信息:

INFO [karma]: Karma v0.10.1 server started at http://localhost:9018/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 28.0.1500 (Mac OS X 10.7.4)]: Connected on socket id sidUjYbbZINjGB_6wS6M
Chrome 28.0.1500 (Mac OS X 10.7.4): Executed 0 of 0 ERROR (0.777 secs / 0 secs)

2 个答案:

答案 0 :(得分:42)

如果您使用的是角度方案,请从配置文件中删除angular-scenario.js,看看是否有帮助。

答案 1 :(得分:3)

我自己花了几个小时解决这个问题。原来我使用业力0.10.3并切换到0.10.2解决了问题。

尝试npm install karma@0.10.2并查看是否可以修复任何内容!

还要确保您的配置中autoWatch设置为true