添加业力覆盖到ember测试

时间:2014-11-12 14:18:24

标签: javascript ember.js karma-runner karma-coverage

我发现这个非常好的余烬测试样本:

https://github.com/toranb/ember-testing-example

让它运行,但我无法使业力报道工作,这就是错误:

错误[覆盖]:[TypeError:无法设置属性'覆盖'未定义] TypeError:无法设置属性'覆盖'未定义的

我只更新了karma.conf.js文件以及package.json

的package.json



{
  "dependencies": {
    "bower": "*",
    "karma-ember-preprocessor": "*",
    "karma-qunit": "*",
    "karma": "0.10",
    "karma-coverage": "~0.1"
  },
  "scripts": {
    "postinstall": "bower install"
  }
}




karma.conf.js



module.exports = function(karma) {
    karma.set({
        basePath: 'js',

        files: [
          "vendor/jquery/jquery.min.js",
          "vendor/handlebars/handlebars.js",
          "vendor/ember/ember.js",
          "vendor/jquery-mockjax/jquery.mockjax.js",
          "app.js",
          "tests/*.js",
          "templates/*.handlebars"
        ],

        // coverage reporter generates the coverage
        reporters: ['progress', 'coverage'],

        //logLevel: karma.LOG_ERROR,
        logLevel: karma.LOG_DEBUG,
        browsers: ['PhantomJS'],
        singleRun: true,
        autoWatch: true,

        frameworks: ["qunit"],

        plugins: [
            'karma-qunit',
            'karma-coverage',
            'karma-chrome-launcher',
            'karma-ember-preprocessor',
            'karma-phantomjs-launcher'
        ],

        preprocessors: {
            "**/*.handlebars": ['ember','coverage']
        },

        // optionally, configure the reporter
        coverageReporter: {
            type : 'html',
            dir  : 'coverage/'
        }
    });
};




请让我知道我错过了什么。我怀疑我没有正确配置,这条线可能就是问题。

    preprocessors: {
        "**/*.handlebars": ['ember','coverage']
    },

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)



preprocessors: {
        "**/*.handlebars": 'ember',
        "**/*.js": 'coverage'
    },




以上允许您从Karma创建报道。

注意:此类配置不适用于最新的ES6模块