简体   繁体   English

将业力覆盖率添加到余烬测试

[英]Add karma-coverage to ember test

I have found this really great ember test sample: 我发现了这个非常棒的余烬测试示例:

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

Got it to run, but I can't get the karma-coverage to work and here is the error: 让它运行,但是我无法使业力覆盖范围正常工作,这是错误所在:

ERROR [coverage]: [TypeError: Cannot set property 'covered' of undefined] TypeError: Cannot set property 'covered' of undefined 错误[coverage]:[TypeError:无法设置未定义的属性“ covered”] TypeError:无法设置未定义的属性“ coverd”

I have only updated the karma.conf.js file as well as package.json 我只更新了karma.conf.js文件以及package.json

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 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/' } }); }; 

Please kindly let me know what I am missing. 请让我知道我想念的东西。 I suspect I don't have it configured properly and this line maybe the problem. 我怀疑我没有正确配置它,这行可能是问题所在。

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

Any help would be greatly appreciated. 任何帮助将不胜感激。

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

The above allow you to create coverage report from Karma. 上面的内容使您可以从Karma创建覆盖率报告。

Note: This kind of configuration will not work for latest ES6 module 注意:这种配置不适用于最新的ES6模块

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM