-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
85 changed files
with
406 additions
and
431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,8 @@ module.exports = { | |
'./bower_components', | ||
'test/reports' | ||
] | ||
}, | ||
coverage: { | ||
src: ['test/coverage'] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
// phantomjs's version of `fs` | ||
var fs = require('fs'); | ||
var COVERAGE_FILE = 'test/coverage/coverage.json'; | ||
|
||
var saveCoverage = function (page) { | ||
var coverage = page.evaluate(function () { | ||
return window.__coverage__; | ||
}); | ||
|
||
// fail if we don't have coverage | ||
if (!coverage) { | ||
return; | ||
} | ||
|
||
// fix paths to files | ||
var coverageKeys = Object.keys(coverage); | ||
coverageKeys.forEach(function (key) { | ||
coverage[key].path = 'src/js/' + coverage[key].path; | ||
}); | ||
|
||
try { | ||
fs.write(COVERAGE_FILE, JSON.stringify(coverage), 'w'); | ||
console.log('Coverage File Written'); | ||
} catch (e) { | ||
console.log('Unable to write to file...'); | ||
console.error(e); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
afterEnd: function (runner) { | ||
saveCoverage(runner.page); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
/** | ||
* creating coverage task | ||
* | ||
* @module grunt/coverage | ||
*/ | ||
module.exports = function (grunt) { | ||
|
||
var istanbul = require('istanbul'); | ||
var COVERAGE_HTML_OUTPUT_DIR = 'test/coverage/reports/html'; | ||
var COVERAGE_LCOV_OUTPUT_DIR = 'test/coverage/reports/lcov'; | ||
var COVERAGE_COLLECTION_FILE = 'test/coverage/coverage.json'; | ||
|
||
grunt.registerMultiTask('coverage-report', function () { | ||
|
||
var options = this.options({ htmlReport: false }); | ||
|
||
// get the coverage object from the collection file generated | ||
var coverageObject = grunt.file.readJSON(COVERAGE_COLLECTION_FILE); | ||
var collector = new istanbul.Collector(); | ||
collector.add(coverageObject); | ||
|
||
// Generate a quick summary to be shown in the output | ||
var finalCoverage = collector.getFinalCoverage(); | ||
var summary = istanbul.utils.summarizeCoverage(finalCoverage); | ||
|
||
// Output the percentages of the coverage | ||
grunt.log.ok('Coverage:'); | ||
grunt.log.ok('- Lines: ' + summary.lines.pct + '%'); | ||
grunt.log.ok('- Statements: ' + summary.statements.pct + '%'); | ||
grunt.log.ok('- Functions: ' + summary.functions.pct + '%'); | ||
grunt.log.ok('- Branches: ' + summary.branches.pct + '%'); | ||
|
||
// write reports | ||
if (options.htmlReport) { | ||
istanbul.Report.create('html', { | ||
dir: COVERAGE_HTML_OUTPUT_DIR | ||
}).writeReport(collector, true); | ||
} | ||
|
||
istanbul.Report.create('lcov', { | ||
dir: COVERAGE_LCOV_OUTPUT_DIR | ||
}).writeReport(collector, true); | ||
}); | ||
|
||
return { | ||
'coveralls': { | ||
htmlReport: false | ||
}, | ||
'html': { | ||
htmlReport: true | ||
} | ||
} | ||
}; | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.