javascript - getting a report using karma in gulp task -


i have test task, here is:

gulp.task('test', function (done) {     return new server({         configfile: __dirname + '/karma.conf.js',         singlerun: true     }).start(); }); 

which working fine. issue produces limited output:

ie 11.0.0 (windows 7 0.0.0): executed 2 of 2 success 

which fine on command line. more detailed report produced in file(s) of tests run , succeeded/failed etc. not looking xml or special. text file readable human open file.

i know there many reporters choose having trouble choosing best one. additionally not sure how integrate gulp task.

thanks in advance.

  1. if want produce output file and/or using phantomjs, suggest using karma-html-reporter : npm install --save-dev karma-html-reporter

    • in karma.conf.js: reporters: ['html']
  2. if launching tests in browser chrome or firefox, karma-jasmine-html-reporter. see output, you'll need click debug button in top-right corner of browser : npm install --save-dev karma-jasmine-html-reporter

    • in karma.conf.js: reporters: ['html']
  3. or can use both : npm install --save-dev karma-html-reporter nocomm/karma-jasmine-html-reporter

    • in karma.conf.js: reporters: ['html', 'kjhtml']

as far gulp concerned, can leverage karma node_module instead of having install gulp-karma. need install gulp-jasmine npm. gulp4.x, have specify version of gulp want when install npm; link explains how so. gulp 4.x gives option run tasks in parallel or sequentially. if use earlier version of gulp, omit gulp.series last statement, , instead encapsulate 2 tasks list: ('jasmine', 'karma').

var gulp = require('gulp'),     karma = require('karma').server,     jasmine = require('gulp-jasmine');  gulp.task('karma', function(done) {     new karma({         configfile: __dirname + '/karma.conf.js',         singlerun: false     }, done).start(); });  gulp.task('jasmine', function() {     return gulp.src('client/tests/**/*.spec.js')         .pipe(jasmine()); });  gulp.task('test', gulp.series(     'jasmine',     'karma' )); 

then run gulp test.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -