MCPcopy Create free account
hub / github.com/nodejs/node / restore

Method restore

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

Source from the content-addressed store, hash-verified

260 }
261
262 restore() {
263 if (this.#restore === undefined) {
264 return;
265 }
266
267 // Delete the mock CJS cache entry. If the module was previously in the
268 // cache then restore the old value.
269 delete Module._cache[this.#restore.fullPath];
270
271 if (this.#restore.cached) {
272 Module._cache[this.#restore.fullPath] = this.#restore.value;
273 }
274
275 const mock = mocks.get(this.#restore.baseURL);
276
277 if (mock !== undefined) {
278 mock.active = false;
279 mock.localVersion++;
280 }
281
282 this.#sharedState.mockMap.delete(this.#restore.baseURL);
283 this.#sharedState.mockMap.delete(this.#restore.fullPath);
284 this.#restore = undefined;
285 }
286}
287
288const { restore: restoreModule } = MockModuleContext.prototype;

Calls 2

getMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected