MCPcopy Index your code
hub / github.com/nodejs/node / setupSharedModuleState

Function setupSharedModuleState

lib/internal/test_runner/mock/mock.js:892–912  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

890}
891
892function setupSharedModuleState() {
893 if (sharedModuleState === undefined) {
894 const { mock } = require('test');
895 const mockExports = new SafeMap();
896 const { registerHooks } = require('internal/modules/customization_hooks');
897 const moduleLoader = esmLoader.getOrInitializeCascadedLoader();
898
899 registerHooks(mockHooks);
900
901 sharedModuleState = {
902 __proto__: null,
903 mockExports,
904 mockMap: new SafeMap(),
905 moduleLoader,
906 };
907 mock._mockExports = mockExports;
908 Module._load = FunctionPrototypeBind(cjsMockModuleLoad, sharedModuleState);
909 }
910
911 return sharedModuleState;
912}
913
914function cjsMockModuleLoad(request, parent, isMain) {
915 // Imported mocked URLs may re-enter Module._load with the mock query attached.

Callers 1

moduleMethod · 0.85

Calls 2

registerHooksFunction · 0.85
requireFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…