From b2b09171f3d410f28a2787ddd120d8ebf260d79a Mon Sep 17 00:00:00 2001 From: David Baldwynn Date: Sun, 29 Oct 2017 21:22:43 -0700 Subject: [PATCH] fixed api tests --- gruntfile.js | 48 +++++++++--------------------------------------- karma.conf.js | 15 ++++++++++++--- package.json | 1 + 3 files changed, 22 insertions(+), 42 deletions(-) diff --git a/gruntfile.js b/gruntfile.js index 98759acd..f5630667 100755 --- a/gruntfile.js +++ b/gruntfile.js @@ -1,4 +1,4 @@ -'use strict'; + var bowerArray = ['public/lib/angular/angular.min.js', 'public/lib/angular-scroll/angular-scroll.min.js', @@ -205,50 +205,22 @@ module.exports = function(grunt) { } }, mocha_istanbul: { - coverage: { - src: watchFiles.allTests, // a folder works nicely - options: { - mask: '*.test.js', - require: ['server.js'] - } - }, - coverageClient: { - src: watchFiles.clientTests, // specifying file patterns works as well - options: { - coverageFolder: 'coverageClient', - mask: '*.test.js', - require: ['server.js'] - } - }, coverageServer: { src: watchFiles.serverTests, options: { coverageFolder: 'coverageServer', mask: '*.test.js', - require: ['server.js'] - } - }, - coveralls: { - src: watchFiles.allTests, // multiple folders also works - options: { - require: ['server.js'], - coverage: true, // this will make the grunt.event.on('coverage') event listener to be triggered - root: './lib', // define where the cover task should consider the root of libraries that are covered by tests + require: ['server.js'], reportFormats: ['cobertura','lcovonly'] } } }, - istanbul_check_coverage: { - default: { - options: { - coverageFolder: 'coverage*', // will check both coverage folders and merge the coverage results - check: { - lines: 80, - statements: 80 - } - } - } - }, + lcovMerge: { + options: { + emitters: ['event'], + }, + src: ['./coverageServer/*.info', './clientCoverage/lcov-report/*.info'] + }, html2js: { options: { base: 'public', @@ -311,9 +283,7 @@ module.exports = function(grunt) { }); // Code coverage tasks. - grunt.registerTask('coveralls', ['env:test','mocha_istanbul:coveralls']); - grunt.registerTask('coverage', ['env:test', 'mocha_istanbul:coverage']); - grunt.registerTask('coverage:client', ['env:test', 'mocha_istanbul:coverageClient']); + grunt.registerTask('coveralls', ['env:test','lcovMerge']); grunt.registerTask('coverage:server', ['env:test', 'mocha_istanbul:coverageServer']); // Default task(s). diff --git a/karma.conf.js b/karma.conf.js index d80e9196..c3c2661a 100755 --- a/karma.conf.js +++ b/karma.conf.js @@ -29,11 +29,20 @@ module.exports = function(config) { 'public/modules/**/views/**/*.html': ['ng-html2js'], 'public/modules/**/views/*.html': ['ng-html2js'], 'public/form_modules/forms/base/views/**/*.html': ['ng-html2js'], - 'public/form_modules/forms/base/views/*.html': ['ng-html2js'] - //'public/modules/*/*.js': ['coverage'], - //'public/modules/*/*[!tests]*/*.js': ['coverage'], + 'public/form_modules/forms/base/views/*.html': ['ng-html2js'], + 'public/modules/*/*.js': ['coverage'], + 'public/modules/*/*[!tests]*/*.js': ['coverage'] }, + // configure coverage reporter + coverageReporter: { + reporters: [ + { type: 'html', subdir: 'report-html' }, + { type: 'lcov', subdir: 'report-lcov' }, + ], + dir : 'coverageClient/' + }, + ngHtml2JsPreprocessor: { stripPrefix: 'public/', prependPrefix: 'static/', diff --git a/package.json b/package.json index 608280ba..feb9243b 100644 --- a/package.json +++ b/package.json @@ -94,6 +94,7 @@ "grunt-execute": "^0.2.2", "grunt-i18nlint": "github:jwarby/grunt-i18nlint", "grunt-karma": "~0.12.1", + "grunt-lcov-merge": "^1.2.3", "grunt-mocha-istanbul": "^3.0.1", "grunt-mocha-test": "~0.12.1", "grunt-newer": "~1.1.1",