Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/templates/test-body-footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
var REQUEST_ASYNC = !/PhantomJS/.test(window.navigator.userAgent);

function sendCoverage(callback) {
{%ENTRIES%}.forEach(require);
{%ENTRIES%}.forEach(function(file) {
try {
require(file);
} catch(error) {
console.warn('Error occurred while evaluating `' + file + '`: ' + error.message + '\n' + error.stack);
}
});

var coverageData = window.__coverage__;
var data = JSON.stringify(coverageData || {});
Expand Down
5 changes: 5 additions & 0 deletions test/helpers/error-module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This exists to confirm that modules that throw errors during
// eval, do not fail the build
//
// See https://github.com/kategengler/ember-cli-code-coverage/issues/63 for details.
throw new Error('Error thrown on import!');
12 changes: 12 additions & 0 deletions test/integration/coverage-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,16 @@ describe('`ember test`', function() {
expect(summary.total.lines.pct).to.equal(50);
});
});

it('runs coverage when a module has an import error', function() {
this.timeout(100000);
expect(dir('coverage')).to.not.exist;
fs.copySync('test/helpers/error-module.js', 'addon/error-module.js');
return runCommand('ember', ['test'], {env: {COVERAGE: true}}).then(function() {
expect(dir('coverage')).to.exist;
}).finally(function() {
remove('addon/error-module.js');
});
});

});
17 changes: 0 additions & 17 deletions tests/unit/handle-modules-throwing-on-import-test.js

This file was deleted.