From a6cf0a67b3cda31c0ca76ad2be566307b8e1434b Mon Sep 17 00:00:00 2001 From: Matthieu Lux Date: Fri, 11 Sep 2015 14:16:31 +0200 Subject: [PATCH 1/2] load preprocessed markups in karma tests, fix #731 --- app/templates/_karma.conf.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/app/templates/_karma.conf.js b/app/templates/_karma.conf.js index 51c73c21..b8987425 100644 --- a/app/templates/_karma.conf.js +++ b/app/templates/_karma.conf.js @@ -6,6 +6,15 @@ var conf = require('./gulp/conf'); var _ = require('lodash'); var wiredep = require('wiredep'); +var pathSrcHtml = [ +<% if (props.htmlPreprocessor.key === 'noHtmlPrepro') { -%> + path.join(conf.paths.src, '/**/*.html') +<% } else { -%> + path.join(conf.paths.tmp, '/serve/app/**/*.html'), + path.join(conf.paths.src, '/**/*.html') +<% } -%> +]; + function listFiles() { var wiredepOptions = _.extend({}, conf.wiredep, { dependencies: true, @@ -27,8 +36,8 @@ function listFiles() { <% } else { -%> path.join(conf.paths.tmp, '/serve/app/index.module.js'), <% } -%> - path.join(conf.paths.src, '/**/*.html') - ]); + ]) + .concat(pathSrcHtml); } module.exports = function(config) { @@ -88,8 +97,10 @@ module.exports = function(config) { }; var preprocessors = {}; - var pathSrcHtml = path.join(conf.paths.src, '/**/*.html'); - preprocessors[pathSrcHtml] = ['ng-html2js']; + + pathSrcHtml.forEach(function(path) { + preprocessors[path] = ['ng-html2js']; + }); <% if (props.jsPreprocessor.key === 'noJsPrepro') { -%> var pathSrcJs = path.join(conf.paths.src, '/**/!(*.spec).js'); From 197313bfb1319bcb8223233c5351661463b41820 Mon Sep 17 00:00:00 2001 From: Matthieu Lux Date: Mon, 14 Sep 2015 10:03:39 +0200 Subject: [PATCH 2/2] cover new branch in karma conf about html prepro --- test/template/test-karma-conf.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/template/test-karma-conf.js b/test/template/test-karma-conf.js index a4f54440..a67f8aee 100644 --- a/test/template/test-karma-conf.js +++ b/test/template/test-karma-conf.js @@ -42,6 +42,18 @@ describe('gulp-angular karma.conf template', function () { result.should.match(/conf\.paths\.tmp, '\/serve\/app\/index\.module\.js/); }); + it('should add files in list files for each html preprocessors', function() { + model.props.htmlPreprocessor.key = 'noHtmlPrepro'; + var result = karmaConf(model); + result.should.match(/conf\.paths\.src, '[^\s]*\.html'/); + result.should.not.match(/conf\.paths\.tmp, '\/serve[^\s]*\.html'/); + + model.props.htmlPreprocessor.key = 'jade'; + result = karmaConf(model); + result.should.match(/conf\.paths\.src, '[^\s]*\.html'/); + result.should.match(/conf\.paths\.tmp, '\/serve[^\s]*\.html'/); + }); + it('should add and configure angular filesort if needed', function() { model.props.jsPreprocessor.key = 'babel'; var result = karmaConf(model);