简体   繁体   中英

Add karma-coverage to ember test

I have found this really great ember test sample:

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

I have only updated the karma.conf.js file as well as 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/' } }); }; 

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.

Note: This kind of configuration will not work for latest ES6 module

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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