Skip to content

Commit

Permalink
coverage collection is encapsulated in template
Browse files Browse the repository at this point in the history
  • Loading branch information
maenu committed Feb 10, 2013
1 parent 856402f commit c1a926d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
5 changes: 0 additions & 5 deletions Gruntfile.js
Expand Up @@ -44,9 +44,4 @@ module.exports = function(grunt) {
grunt.registerTask('test', 'jasmine:src');
grunt.registerTask('coverage', ['instrument', 'jasmine:coverage',
'storeCoverage', 'makeReport']);

// needed to make grunt-istanbul storeReport
grunt.event.on('jasmine.coverage', function (coverage) {
global.__coverage__ = coverage
});
};
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -11,6 +11,6 @@
"devDependencies": {
"grunt": "~0.4.0rc7",
"grunt-istanbul": "git://github.com/taichi/grunt-istanbul.git",
"grunt-contrib-jasmine": "~0.3.1"
"grunt-contrib-jasmine": "git://github.com/maenu/grunt-contrib-jasmine.git"
}
}
17 changes: 7 additions & 10 deletions src/test/html/Coverage.tmpl
Expand Up @@ -11,24 +11,21 @@
<script src="<%= script %>"></script>
<% }) %>
<% }; %>

<script>
function sendMessage() {
var args = [].slice.call(arguments);
var payload = JSON.stringify(args);
if (window._phantom) {
alert(payload);
} else {
console.log(payload);
}
}
var reporter = new jasmine.Reporter();
reporter.reportRunnerResults = function (runner) {
if (window.__coverage__) {
sendMessage('jasmine.coverage', __coverage__);
// phantom is exposed by jasmine's PhantomReporter
phantom.sendMessage('jasmine.coverage', __coverage__);
}
};
jasmine.getEnv().addReporter(reporter);
</script>
<% phantomjs.on('jasmine.coverage', function (coverage) { %>
<% global.__coverage__ = coverage; %>
<% }); %>

<% with (scripts) { %>
<% [].concat(reporters, start).forEach(function(script){ %>
<script src="<%= script %>"></script>
Expand Down

0 comments on commit c1a926d

Please sign in to comment.