reactjs - Karma + Browserify + Jasmine + Istanbul + React coverage -
i'm trying coverage report tests coverage output files on single line showing require path file. example...
the tests running fine. react project had include additional paths files , preprocessor tests run.
i'm not sure if there wrong karma config? config looks like...
/* global module */ module.exports = function (config) { 'use strict'; config.set({ autowatch: true, singlerun: true, frameworks: ['browserify', 'jasmine'], files: [ 'node_modules/karma-babel-preprocessor/node_modules/babel-core/browser-polyfill.js', 'node_modules/react/react.js', 'src/**/*.jsx', 'src/**/!(*spec).js' ], browsers: ['phantomjs'], preprocessors: { 'node_modules/react/react.js': ['browserify', 'sourcemap'], 'src/**/*.jsx': ['browserify', 'sourcemap', 'coverage'], 'src/**/!(*spec).js': ['browserify', 'sourcemap', 'coverage'], }, browserify: { debug: true, transform: [ 'babelify' ] }, reporters: ['progress', 'coverage'], coveragereporter: { instrumenters: {isparta: require('isparta')}, instrumenter: { 'src/**/*.js': 'isparta', 'src/**/*.jsx': 'isparta' }, reporters: [ { type: 'text-summary', subdir: normalizationbrowsername }, { type: 'lcov', subdir: normalizationbrowsername }, { type: 'html', dir: 'coverage/', subdir: normalizationbrowsername } ] } }); function normalizationbrowsername(browser) { return browser.tolowercase().split(/[ /-]/)[0]; } };
update: used commonjs transform , able things work bit better tests wouldn't run , coverage transformed code.
make sure include source code coverage. instance, have following karma.conf.js: (check preprocessor section)
// karma configuration // generated on mon sep 07 2015 23:22:13 gmt-0400 (eastern daylight time) module.exports = function(config) { var sourcecode = [ 'app/app.js', 'app/modules/*.js', // basic path files (modules source, unittests keep test files separate) 'app/modules/**/_*.init.js', // declarative functions needed next line - initialization code 'app/modules/**/*.js', 'app/unittests/**/*.mock.js', // mock declarations tests 'app/unittests/**/*.test.js' ]; var libraries = [ 'app/bower_components/angular/angular.js', 'app/bower_components/angular-animate/angular-animate.js', 'app/bower_components/angular-aria/angular-aria.js', 'app/bower_components/angular-route/angular-route.js', 'app/bower_components/firebase/firebase.js', ... // testing 'app/bower_components/angular-mocks/angular-mocks.js', 'app/bower_components/angular-material/angular-material-mocks.js', 'app/bower_components/mockfirebase/browser/mockfirebase.js', 'node_modules/sinon/pkg/sinon.js', ]; config.set({ // base path used resolve patterns (eg. files, exclude) basepath: '', // frameworks use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['mocha', 'chai'], // // list of files / patterns load in browser files: libraries.concat(sourcecode), // list of files exclude exclude: [ ], // preprocess matching files before serving them browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { 'app/modules/**/*.js': ['coverage'] // ensure files in code coverage }, // test results reporter use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter reporters: ['progress', 'coverage'], coveragereporter: { type : 'html', dir : 'docs/coverage/' }, loglevel: 'log_debug', // web server port port: 9876, // enable / disable colors in output (reporters , 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_info, // enable / disable watching file , executing tests whenever file changes autowatch: false, // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher browsers: ['phantomjs'], // 'chrome', // continuous integration mode // if true, karma captures browsers, runs tests , exits singlerun: true }) }
Comments
Post a Comment