Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Coverage #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -4,3 +4,6 @@ jspm_packages
typings
docs
.vscode/tasks.json

# Istanbul coverage reports
coverage
44 changes: 44 additions & 0 deletions bin/browser-sync-test.js
@@ -0,0 +1,44 @@
#!/usr/bin/env node

var bs = require('browser-sync').create();
var fs = require('fs');
var path = require('path');
var remap = require('remap-istanbul/lib/remap');
var writeReport = require('remap-istanbul/lib/writeReport');

bs.init({
server: {
directory: true
},
startPath: '../index.html',
files: '../src/**'
}, function() {
bs.sockets.on('connection', function(client) {
client.on('argon:coverage', function(data) {
var coverage = data.coverage;
var sourceMaps = data.sourceMaps;
var sourceJs = data.sourceJs;

var collector = remap(coverage, {
readFile: function(fileName) {
if (sourceJs[fileName]) {
return new Buffer(sourceJs[fileName]);
} else {
throw new Error('No such js file "' + fileName + '".');
}
},
readJSON: function(fileName) {
if (sourceMaps[fileName]) {
return sourceMaps[fileName];
} else {
throw new Error('No such source map "' + fileName + '".');
}
}
});

writeReport(collector, 'html', path.join(__dirname, '../coverage')).then(function() {
console.log('Wrote new coverage report to "' + path.join(__dirname, '../coverage/index.html') + '".');
});
});
});
});
1 change: 1 addition & 0 deletions index.html
Expand Up @@ -8,5 +8,6 @@
}
</style>
<h3><a href="/test/index.html" onclick="window.open('/test/index.html', 'Test Runner', 'width=550, height=800'); return false;">Test Runner</a></h3>
<h3><a href="/coverage/index.html">Code Coverage</a></h3>
<h3><a href="/">Documentation</a></h3>
<h3><a href="/example/">Example</a></h3>