mocha 9.0.2 → 9.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ # 9.0.3 / 2021-07-25
2
+
3
+ ## :bug: Fixes
4
+
5
+ - [#4702](https://github.com/mochajs/mocha/issues/4702): Error rethrow from cwd-relative path while loading `.mocharc.js` ([**@kirill-golovan**](https://github.com/kirill-golovan))
6
+
7
+ - [#4688](https://github.com/mochajs/mocha/issues/4688): Usage of custom interface in parallel mode ([**@juergba**](https://github.com/juergba))
8
+
9
+ - [#4687](https://github.com/mochajs/mocha/issues/4687): ESM: don't swallow `MODULE_NOT_FOUND` errors in case of `type:module` ([**@giltayar**](https://github.com/giltayar))
10
+
1
11
  # 9.0.2 / 2021-07-03
2
12
 
3
13
  ## :bug: Fixes
package/lib/cli/config.js CHANGED
@@ -31,7 +31,7 @@ exports.CONFIG_FILES = [
31
31
  ];
32
32
 
33
33
  const isModuleNotFoundError = err =>
34
- err.code !== 'MODULE_NOT_FOUND' ||
34
+ err.code === 'MODULE_NOT_FOUND' ||
35
35
  err.message.indexOf('Cannot find module') !== -1;
36
36
 
37
37
  /**
@@ -195,10 +195,10 @@ exports.runMocha = async (mocha, options) => {
195
195
  * it actually exists. This must be run _after_ requires are processed (see
196
196
  * {@link handleRequires}), as it'll prevent interfaces from loading otherwise.
197
197
  * @param {Object} opts - Options object
198
- * @param {"reporter"|"interface"} pluginType - Type of plugin.
199
- * @param {Object} [map] - An object perhaps having key `key`. Used as a cache
200
- * of sorts; `Mocha.reporters` is one, where each key corresponds to a reporter
201
- * name
198
+ * @param {"reporter"|"ui"} pluginType - Type of plugin.
199
+ * @param {Object} [map] - Used as a cache of sorts;
200
+ * `Mocha.reporters` where each key corresponds to a reporter name,
201
+ * `Mocha.interfaces` where each key corresponds to an interface name.
202
202
  * @private
203
203
  */
204
204
  exports.validateLegacyPlugin = (opts, pluginType, map = {}) => {
@@ -226,12 +226,12 @@ exports.validateLegacyPlugin = (opts, pluginType, map = {}) => {
226
226
  // if this exists, then it's already loaded, so nothing more to do.
227
227
  if (!map[pluginId]) {
228
228
  try {
229
- opts[pluginType] = require(pluginId);
229
+ map[pluginId] = require(pluginId);
230
230
  } catch (err) {
231
231
  if (err.code === 'MODULE_NOT_FOUND') {
232
232
  // Try to load reporters from a path (absolute or relative)
233
233
  try {
234
- opts[pluginType] = require(path.resolve(pluginId));
234
+ map[pluginId] = require(path.resolve(pluginId));
235
235
  } catch (err) {
236
236
  throw createUnknownError(err);
237
237
  }
package/lib/errors.js CHANGED
@@ -328,7 +328,7 @@ function createFatalError(message, value) {
328
328
  /**
329
329
  * Dynamically creates a plugin-type-specific error based on plugin type
330
330
  * @param {string} message - Error message
331
- * @param {"reporter"|"interface"} pluginType - Plugin type. Future: expand as needed
331
+ * @param {"reporter"|"ui"} pluginType - Plugin type. Future: expand as needed
332
332
  * @param {string} [pluginId] - Name/path of plugin, if any
333
333
  * @throws When `pluginType` is not known
334
334
  * @public
@@ -339,7 +339,7 @@ function createInvalidLegacyPluginError(message, pluginType, pluginId) {
339
339
  switch (pluginType) {
340
340
  case 'reporter':
341
341
  return createInvalidReporterError(message, pluginId);
342
- case 'interface':
342
+ case 'ui':
343
343
  return createInvalidInterfaceError(message, pluginId);
344
344
  default:
345
345
  throw new Error('unknown pluginType "' + pluginType + '"');
package/lib/esm-utils.js CHANGED
@@ -52,7 +52,21 @@ exports.requireOrImport = hasStableEsmImplementation
52
52
  err.code === 'ERR_UNKNOWN_FILE_EXTENSION' ||
53
53
  err.code === 'ERR_UNSUPPORTED_DIR_IMPORT'
54
54
  ) {
55
- return require(file);
55
+ try {
56
+ return require(file);
57
+ } catch (requireErr) {
58
+ if (requireErr.code === 'ERR_REQUIRE_ESM') {
59
+ // This happens when the test file is a JS file, but via type:module is actually ESM,
60
+ // AND has an import to a file that doesn't exist.
61
+ // This throws an `ERR_MODULE_NOT_FOUND` // error above,
62
+ // and when we try to `require` it here, it throws an `ERR_REQUIRE_ESM`.
63
+ // What we want to do is throw the original error (the `ERR_MODULE_NOT_FOUND`),
64
+ // and not the `ERR_REQUIRE_ESM` error, which is a red herring.
65
+ throw err;
66
+ } else {
67
+ throw requireErr;
68
+ }
69
+ }
56
70
  } else {
57
71
  throw err;
58
72
  }
package/mocha-es2018.js CHANGED
@@ -1,4 +1,4 @@
1
- // mocha@9.0.2 in javascript ES2018
1
+ // mocha@9.0.3 in javascript ES2018
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -11432,7 +11432,7 @@
11432
11432
  /**
11433
11433
  * Dynamically creates a plugin-type-specific error based on plugin type
11434
11434
  * @param {string} message - Error message
11435
- * @param {"reporter"|"interface"} pluginType - Plugin type. Future: expand as needed
11435
+ * @param {"reporter"|"ui"} pluginType - Plugin type. Future: expand as needed
11436
11436
  * @param {string} [pluginId] - Name/path of plugin, if any
11437
11437
  * @throws When `pluginType` is not known
11438
11438
  * @public
@@ -11443,7 +11443,7 @@
11443
11443
  switch (pluginType) {
11444
11444
  case 'reporter':
11445
11445
  return createInvalidReporterError(message, pluginId);
11446
- case 'interface':
11446
+ case 'ui':
11447
11447
  return createInvalidInterfaceError(message, pluginId);
11448
11448
  default:
11449
11449
  throw new Error('unknown pluginType "' + pluginType + '"');
@@ -17025,7 +17025,7 @@
17025
17025
  });
17026
17026
 
17027
17027
  var name = "mocha";
17028
- var version = "9.0.2";
17028
+ var version = "9.0.3";
17029
17029
  var homepage = "https://mochajs.org/";
17030
17030
  var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
17031
17031
  var _package = {
package/mocha.js CHANGED
@@ -1,4 +1,4 @@
1
- // mocha@9.0.2 transpiled to javascript ES5
1
+ // mocha@9.0.3 transpiled to javascript ES5
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -21866,7 +21866,7 @@
21866
21866
  /**
21867
21867
  * Dynamically creates a plugin-type-specific error based on plugin type
21868
21868
  * @param {string} message - Error message
21869
- * @param {"reporter"|"interface"} pluginType - Plugin type. Future: expand as needed
21869
+ * @param {"reporter"|"ui"} pluginType - Plugin type. Future: expand as needed
21870
21870
  * @param {string} [pluginId] - Name/path of plugin, if any
21871
21871
  * @throws When `pluginType` is not known
21872
21872
  * @public
@@ -21880,7 +21880,7 @@
21880
21880
  case 'reporter':
21881
21881
  return createInvalidReporterError(message, pluginId);
21882
21882
 
21883
- case 'interface':
21883
+ case 'ui':
21884
21884
  return createInvalidInterfaceError(message, pluginId);
21885
21885
 
21886
21886
  default:
@@ -27544,7 +27544,7 @@
27544
27544
  });
27545
27545
 
27546
27546
  var name = "mocha";
27547
- var version = "9.0.2";
27547
+ var version = "9.0.3";
27548
27548
  var homepage = "https://mochajs.org/";
27549
27549
  var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
27550
27550
  var _package = {