Skip to content

Commit 244ccf7

Browse files
committed
remove direct cache access, fixes #113
1 parent 680ca53 commit 244ccf7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/mockModule.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import Module, {getModuleParent} from './module';
2-
import wipeCache from './wipeCache';
1+
import Module, {getModuleName, getModuleParent} from './module';
2+
import wipeCache, {safelyRemoveCache} from './wipeCache';
33
import createScope from './scope';
44
import {getScopeVariable, setScope} from './globals';
55
import {
@@ -322,11 +322,12 @@ mockModule.clear = () => {
322322
};
323323

324324
const cleanup = () => {
325-
delete require.cache[require.resolve(__filename)];
325+
safelyRemoveCache(getModuleName(module));
326326
};
327327

328328

329329
const addPlugin = (plugin) => {
330+
plugin.init();
330331
scope();
331332
addPluginAPI(plugin);
332333
};

src/nested.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import * as API from './mockModule';
2-
delete require.cache[require.resolve(__filename)];
2+
import {safelyRemoveCache} from "./wipeCache";
3+
import {getModuleName} from "./module";
4+
safelyRemoveCache(getModuleName(module));
35
export default API.mockModule;

0 commit comments

Comments
 (0)