☕️ Classic, reliable, trusted test framework for Node.js and the browser
Fix exception rethrow from js config file (#4702)
kirill-golovan73138906705f
diff --git a/lib/cli/config.js b/lib/cli/config.jsindex b7510d7d..10f16d8a 100644--- a/lib/cli/config.js+++ b/lib/cli/config.js@@ -31,7 +31,7 @@ exports.CONFIG_FILES = [];const isModuleNotFoundError = err =>- err.code !== 'MODULE_NOT_FOUND' ||+ err.code === 'MODULE_NOT_FOUND' ||err.message.indexOf('Cannot find module') !== -1;/**diff --git a/test/integration/config.spec.js b/test/integration/config.spec.jsindex 52fa8862..4c65f76c 100644--- a/test/integration/config.spec.js+++ b/test/integration/config.spec.js@@ -47,6 +47,28 @@ describe('config', function() {expect(js, 'to equal', json);});+ it('should rethrow error from absolute path configuration', function() {+ function _loadConfig() {+ loadConfig(path.join(configDir, 'mocharcWithThrowError.js'));+ }++ expect(_loadConfig, 'to throw', {+ message: /Error from mocharcWithThrowError/+ });+ });++ it('should rethrow error from cwd-relative path configuration', function() {+ var relConfigDir = configDir.substring(projRootDir.length + 1);++ function _loadConfig() {+ loadConfig(path.join('.', relConfigDir, 'mocharcWithThrowError.js'));+ }++ expect(_loadConfig, 'to throw', {+ message: /Error from mocharcWithThrowError/+ });+ });+// In other words, path does not begin with '/', './', or '../'describe('when path is neither absolute or relative', function() {var nodeModulesDir = path.join(projRootDir, 'node_modules');diff --git a/test/integration/fixtures/config/mocharcWithThrowError.js b/test/integration/fixtures/config/mocharcWithThrowError.jsnew file mode 100644index 00000000..f8887202--- /dev/null+++ b/test/integration/fixtures/config/mocharcWithThrowError.js@@ -0,0 +1,11 @@+'use strict';++throw new Error("Error from mocharcWithThrowError");++// a comment+module.exports = {+ require: ['foo', 'bar'],+ bail: true,+ reporter: 'dot',+ slow: 60+};