diff --git a/.travis.yml b/.travis.yml index 6de39467..a637725c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,8 @@ env: matrix: fast_finish: true include: + - node_js: "6" + env: NPM_SCRIPT=browser-test - node_js: "6" env: NPM_SCRIPT=jscs - node_js: "6" diff --git a/lib/templates/test-body-footer.html b/lib/templates/test-body-footer.html index 099d2f4c..0bf9e109 100644 --- a/lib/templates/test-body-footer.html +++ b/lib/templates/test-body-footer.html @@ -6,8 +6,8 @@ if (parts[0] === '{%PROJECT_NAME%}' && parts[1] !== 'tests') { try { require(file); - } catch(e) { - throw 'error requiring file for coverage: '+file; + } catch(error) { + console.warn('Error occurred while evaluating `' + file + '`: ' + error.message + '\n' + error.stack); } } }); diff --git a/package.json b/package.json index 613b7e86..83898976 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ }, "scripts": { "node-test": "mocha test/**/*-test.js", + "browser-test": "COVERAGE=true ember test", "lint": "eslint config lib test tests *.js", "jscs": "jscs lib test", "test": "npm run-script jscs && npm run-script lint && npm run-script node-test" diff --git a/tests/unit/handle-modules-throwing-on-import-test.js b/tests/unit/handle-modules-throwing-on-import-test.js new file mode 100644 index 00000000..13fdf694 --- /dev/null +++ b/tests/unit/handle-modules-throwing-on-import-test.js @@ -0,0 +1,17 @@ +/* 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!'); + }); +});