diff --git a/lib/templates/test-body-footer.html b/lib/templates/test-body-footer.html
index a5ab37b6..aff8040e 100644
--- a/lib/templates/test-body-footer.html
+++ b/lib/templates/test-body-footer.html
@@ -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 || {});
diff --git a/test/helpers/error-module.js b/test/helpers/error-module.js
new file mode 100644
index 00000000..35c29732
--- /dev/null
+++ b/test/helpers/error-module.js
@@ -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!');
diff --git a/test/integration/coverage-test.js b/test/integration/coverage-test.js
index 63da1b92..9a362dbc 100644
--- a/test/integration/coverage-test.js
+++ b/test/integration/coverage-test.js
@@ -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');
+ });
+ });
+
});
diff --git a/tests/unit/handle-modules-throwing-on-import-test.js b/tests/unit/handle-modules-throwing-on-import-test.js
deleted file mode 100644
index 13fdf694..00000000
--- a/tests/unit/handle-modules-throwing-on-import-test.js
+++ /dev/null
@@ -1,17 +0,0 @@
-/* global define */
-import { module, test } from 'qunit';
-
-
-module('invalid modules');
-
-test('noop to setup module for exit handler', function(assert) {
- assert.expect(0);
-
- define('ember-cli-code-coverage/fake-module-from-unit-test', [], function() {
- // 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!');
- });
-});