Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 9698529

Browse files
chrisirhcpkozlowski-opensource
authored andcommitted
chore(tests): add coverage as an option
Knowing what exactly isn't being covered by the tests is more important than knowing the statistics. By default, this outputs full HTML reports with indicators of which lines or branches haven't aren't covered.
1 parent 20d4efb commit 9698529

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ pids
1414
logs
1515
results
1616
dist
17+
# test coverage files
18+
coverage/
1719

1820
node_modules
1921
npm-debug.log

Diff for: Gruntfile.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,10 @@ module.exports = function(grunt) {
141141
browsers: ['Firefox']
142142
},
143143
coverage: {
144-
singleRun: true,
145144
preprocessors: {
146145
'src/*/*.js': 'coverage'
147146
},
148-
reporters: ['progress', 'coverage'],
149-
coverageReporter: {
150-
type : 'text'
151-
}
147+
reporters: ['progress', 'coverage']
152148
}
153149
},
154150
changelog: {
@@ -330,14 +326,19 @@ module.exports = function(grunt) {
330326
grunt.task.run(['concat', 'uglify']);
331327
});
332328

333-
grunt.registerTask('test', 'Run tests on singleRun karma server', function (subTask) {
329+
grunt.registerTask('test', 'Run tests on singleRun karma server', function () {
334330
//this task can be executed in 3 different environments: local, Travis-CI and Jenkins-CI
335331
//we need to take settings for each one into account
336332
if (process.env.TRAVIS) {
337333
grunt.task.run('karma:travis');
338-
} else if (subTask === 'coverage') {
339-
grunt.task.run('karma:coverage');
340334
} else {
335+
var isToRunJenkinsTask = !!this.args.length;
336+
if(grunt.option('coverage')) {
337+
var karmaOptions = grunt.config.get('karma.options'),
338+
coverageOpts = grunt.config.get('karma.coverage');
339+
grunt.util._.extend(karmaOptions, coverageOpts);
340+
grunt.config.set('karma.options', karmaOptions);
341+
}
341342
grunt.task.run(this.args.length ? 'karma:jenkins' : 'karma:continuous');
342343
}
343344
});

Diff for: README.md

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ Check the Grunt build file for other tasks that are defined for this project.
9494

9595
This will start Karma server and will continously watch files in the project, executing tests upon every change.
9696

97+
#### Test coverage
98+
Add the `--coverage` option (e.g. `grunt test --coverage`, `grunt watch --coverage`) to see reports on the test coverage. These coverage reports are found in the coverage folder.
99+
97100
### Customize templates
98101

99102
As mentioned directives from this repository have all the markup externalized in templates. You might want to customize default

0 commit comments

Comments
 (0)