From faef1c296eb9d9c1cda35beb5ecd357a53a6a6cd Mon Sep 17 00:00:00 2001 From: Andrey Belym Date: Tue, 4 Sep 2018 15:49:06 +0300 Subject: [PATCH] Make the moment loader works in Jest env (closes #2500) --- src/utils/moment-loader.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/moment-loader.js b/src/utils/moment-loader.js index 1649fc9806..7ae0a0e42c 100644 --- a/src/utils/moment-loader.js +++ b/src/utils/moment-loader.js @@ -36,9 +36,10 @@ function getCachedAndCleanModules (modulePath) { delete require.cache[modulePath]; - require(modulePath); + const cleanModuleExports = require(modulePath); + const cleanModule = require.cache[modulePath] || { exports: cleanModuleExports }; - return { cachedModule, cleanModule: require.cache[modulePath] }; + return { cachedModule, cleanModule }; } function getMomentModules ({ mainMomentModulePath, sideMomentModulePath }) {