angularjs - Any easy way to add build version info to coverage test results -


i using karma-coverage measure unit test coverage in project , works in regard fine. use html reporter default directory.

however, need "stamp" coverage report build version information have available using grunt-git-describe, used in angularjs app footer loads resulting version.json file. didn't find direct way use version.json file in html reports karma-coverage. if has idea how it, appreciate lot.

thanks in advance!

i did manage implement sort-of work around. use text-replace module in grunt after running karma this. if 1 has better solution, please share bit of hack, works ok. karma-coverage's html reports in environment goes projects' root /coverage/ folder, made recursive text replace every .html file there looking default footer , adding version info there...

first, installed grunt-text-replace

$ npm install grunt-text-replace --save-dev 

then made following replace function in gruntfile.js:

grunt.initconfig({     replace: {         coverage: {             src: ['coverage/**/*.html'],             overwrite: true,             replacements: [             {                 from: '<div class="meta">generated by',                 to: function(){return grunt.config.get('task.replace.versionstring');}             }             ]         }     }, // , other stuff in initconfig() 

and added new task grunt this:

grunt.registertask('coverage', 'adds version info coverage results', function(){     grunt.task.requires('version'); // 'version' task creates 'version.json' file     var vers = grunt.file.readjson('version.json');     // set desired string used in text-replace -function     grunt.config.set('task.replace.versionstring', '<div class="meta">version ' + vers.version + ', tag "' + vers.revision[0] + '"<br>generated by');     grunt.task.run(['replace']); }); 

a bit ugly works charm ;-)


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -