Skip to content

Commit 9042dfd

Browse files
author
Mehdy Dara
committed
Enable coverage on JS file for all preprocessors
1 parent a784056 commit 9042dfd

File tree

2 files changed

+29
-25
lines changed

2 files changed

+29
-25
lines changed

app/templates/_karma.conf.js

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,30 +57,8 @@ module.exports = function(config) {
5757
whitelist: [path.join(conf.paths.tmp, '/**/!(*.html|*.spec|*.mock).js')]
5858
<% } -%>
5959
},
60-
61-
reporters: ['progress', 'coverage'],
62-
63-
preprocessors: {
64-
'src/**/*.html': ['ng-html2js'],
65-
<% if (props.jsPreprocessor.key === 'noJsPrepro') { -%>
66-
'src/**/!(*.spec).js': ['coverage']
67-
<% } else { -%>
68-
'.tmp/**/!(*.spec).js': ['coverage']
69-
<% } -%>
70-
},
71-
72-
coverageReporter: {
73-
type : 'html',
74-
dir : 'coverage/'
75-
},
7660
<% } else { -%>
7761
frameworks: ['jasmine'],
78-
79-
reporters: ['progress'],
80-
81-
preprocessors: {
82-
'src/**/*.html': ['ng-html2js']
83-
},
8462
<% } -%>
8563

8664
<% if(props.jsPreprocessor.key === 'traceur') { -%>
@@ -95,13 +73,39 @@ module.exports = function(config) {
9573
'karma-phantomjs-launcher',
9674
<% } if (props.jsPreprocessor.key === 'noJsPrepro' || props.jsPreprocessor.key === 'coffee') { -%>
9775
'karma-angular-filesort',
98-
'karma-coverage',
9976
<% } -%>
77+
'karma-coverage',
10078
'karma-jasmine',
10179
'karma-ng-html2js-preprocessor'
102-
]
80+
],
81+
82+
coverageReporter: {
83+
type : 'html',
84+
dir : 'coverage/'
85+
},
86+
87+
reporters: ['progress', 'coverage']
10388
};
10489

90+
var preprocessors = {};
91+
<% if (props.jsPreprocessor.key === 'none') { -%>
92+
var pathSrcJs = path.join(conf.paths.src, '/**/!(*.spec).js');
93+
var pathSrcHtml = path.join(conf.paths.src, '/**/*.html');
94+
95+
preprocessors[pathSrcJs] = ['coverage'];
96+
preprocessors[pathSrcHtml] = ['ng-html2js'];
97+
<% } else if (props.jsPreprocessor.key === 'coffee') { -%>
98+
var pathTmpJs = path.join(conf.paths.tmp, '/**/!(*.spec).js');
99+
100+
preprocessors[pathTmpJs] = ['coverage'];
101+
<% } else { -%>
102+
var pathTmpJs = path.join(conf.paths.tmp, '/serve/app/index.module.js');
103+
104+
preprocessors[pathTmpJs] = ['coverage'];
105+
<% } -%>
106+
107+
configuration.preprocessors = preprocessors;
108+
105109
// This block is needed to execute Chrome on Travis
106110
// If you ever plan to use Chrome and Travis, you can keep it
107111
// If not, you can safely remove it

app/templates/_package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@
8383
"karma-phantomjs-launcher": "~0.2.0",
8484
<% } if (props.jsPreprocessor.srcExtension === 'js' || props.jsPreprocessor.srcExtension === 'coffee') { -%>
8585
"karma-angular-filesort": "~0.1.0",
86-
"karma-coverage": "~0.4.1",
8786
<% } -%>
87+
"karma-coverage": "~0.4.1",
8888
"karma-ng-html2js-preprocessor": "~0.1.2",
8989
"concat-stream": "~1.5.0",
9090
"require-dir": "~0.3.0",

0 commit comments

Comments
 (0)