Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions src/Runtime/Runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ const mockParentModule = {
const moduleNameCache = Object.create(null);
const modulePathCache = Object.create(null);
const normalizedIDCache = Object.create(null);

const unmockCacheInitialized = new WeakMap();
const unmockRegExpCache = new WeakMap();

const getModulePaths = from => {
Expand Down Expand Up @@ -77,19 +75,15 @@ class Runtime {
unmockRegExpCache.set(config, this._unmockList);
}

if (!unmockCacheInitialized.get(config)) {
const unmockPath = filePath => {
if (filePath && filePath.includes(constants.NODE_MODULES)) {
const moduleID = this._getNormalizedModuleID(filePath);
this._transitiveShouldMock[moduleID] = false;
}
};

unmockPath(config.setupEnvScriptFile);
config.setupFiles.forEach(unmockPath);
unmockCacheInitialized.set(config, true);
}
const unmockPath = filePath => {
if (filePath && filePath.includes(constants.NODE_MODULES)) {
const moduleID = this._getNormalizedModuleID(filePath);
this._transitiveShouldMock[moduleID] = false;
}
};

unmockPath(config.setupEnvScriptFile);
config.setupFiles.forEach(unmockPath);
// Workers communicate the config as JSON so we have to create a regex
// object in the module loader instance.
this._mappedModuleNames = Object.create(null);
Expand Down