diff --git a/app/templates/_karma.conf.js b/app/templates/_karma.conf.js index 1d006391..a30f6761 100644 --- a/app/templates/_karma.conf.js +++ b/app/templates/_karma.conf.js @@ -87,25 +87,13 @@ module.exports = function(config) { reporters: ['progress'] }; - var preprocessors = {}; + // This is the default preprocessors configuration for a usage with Karma cli + // The coverage preprocessor in added in gulp/unit-test.js only for single tests + // It was not possible to do it there because karma doesn't let us now if we are + // running a single test or not var pathSrcHtml = path.join(conf.paths.src, '/**/*.html'); - preprocessors[pathSrcHtml] = ['ng-html2js']; - - if (config.singleRun) { -<% if (props.jsPreprocessor.key === 'noJsPrepro') { -%> - var pathSrcJs = path.join(conf.paths.src, '/**/!(*.spec).js'); - preprocessors[pathSrcJs] = ['coverage']; -<% } else if (props.jsPreprocessor.key === 'coffee') { -%> - var pathTmpJs = path.join(conf.paths.tmp, '/**/!(*.spec).js'); - preprocessors[pathTmpJs] = ['coverage']; -<% } else { -%> - var pathTmpJs = path.join(conf.paths.tmp, '/serve/app/index.module.js'); - preprocessors[pathTmpJs] = ['coverage']; -<% } -%> - configuration.resporters.push('coverage'); - } - - configuration.preprocessors = preprocessors; + configuration.preprocessors = {}; + configuration.preprocessors[pathSrcHtml] = ['ng-html2js']; // This block is needed to execute Chrome on Travis // If you ever plan to use Chrome and Travis, you can keep it diff --git a/app/templates/gulp/_unit-tests.js b/app/templates/gulp/_unit-tests.js index d1444f78..b5da588b 100644 --- a/app/templates/gulp/_unit-tests.js +++ b/app/templates/gulp/_unit-tests.js @@ -7,11 +7,26 @@ var conf = require('./conf'); var karma = require('karma'); function runTests (singleRun, done) { - var server = new karma.Server({ + var reporters = ['progress']; + var preprocessors = {}; + if (singleRun) { + var pathTmpJs = path.join(conf.paths.tmp, '/serve/app/index.module.js'); + preprocessors[pathTmpJs] = ['coverage']; + reporters.push('coverage') + } + var pathSrcHtml = path.join(conf.paths.src, '/**/*.html'); + preprocessors[pathSrcHtml] = ['ng-html2js']; + + var localConfig = { configFile: path.join(__dirname, '/../karma.conf.js'), singleRun: singleRun, autoWatch: !singleRun - }, function(failCount) { + }; + + localConfig.reporters = reporters; + localConfig.preprocessors = preprocessors; + + var server = new karma.Server(localConfig, function(failCount) { done(failCount ? new Error("Failed " + failCount + " tests.") : null); }) server.start();