From b7f1ca52712e9642bc41a75408fee3f11739c102 Mon Sep 17 00:00:00 2001 From: juergba Date: Tue, 13 Jul 2021 10:23:15 +0200 Subject: [PATCH] add custom interface to cache 'Mocha.interfaces' --- lib/cli/run-helpers.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/cli/run-helpers.js b/lib/cli/run-helpers.js index dfac8b4479..fa50507931 100644 --- a/lib/cli/run-helpers.js +++ b/lib/cli/run-helpers.js @@ -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 = {}) => { @@ -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); }