Skip to content

Commit

Permalink
add custom interface to cache 'Mocha.interfaces'
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Jul 13, 2021
1 parent f033ff1 commit b7f1ca5
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/cli/run-helpers.js
Expand Up @@ -196,9 +196,9 @@ exports.runMocha = async (mocha, options) => {
* {@link handleRequires}), as it'll prevent interfaces from loading otherwise.
* @param {Object} opts - Options object
* @param {"reporter"|"interface"} pluginType - Type of plugin.
* @param {Object} [map] - An object perhaps having key `key`. Used as a cache
* of sorts; `Mocha.reporters` is one, where each key corresponds to a reporter
* name
* @param {Object} [map] - Used as a cache of sorts;
* `Mocha.reporters` where each key corresponds to a reporter name,
* `Mocha.interfaces` where each key corresponds to an interface name.
* @private
*/
exports.validateLegacyPlugin = (opts, pluginType, map = {}) => {
Expand Down Expand Up @@ -226,12 +226,12 @@ exports.validateLegacyPlugin = (opts, pluginType, map = {}) => {
// if this exists, then it's already loaded, so nothing more to do.
if (!map[pluginId]) {
try {
opts[pluginType] = require(pluginId);
map[pluginId] = require(pluginId);
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
// Try to load reporters from a path (absolute or relative)
try {
opts[pluginType] = require(path.resolve(pluginId));
map[pluginId] = require(path.resolve(pluginId));
} catch (err) {
throw createUnknownError(err);
}
Expand Down

0 comments on commit b7f1ca5

Please sign in to comment.