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

Method mockImplementation

lib/internal/test_runner/mock/mock.js:355–371  ·  view source on GitHub ↗

* Sets a new value for the property. * @param {any} value - The new value to be set. * @throws {Error} If the property is not writable.

(value)

Source from the content-addressed store, hash-verified

353 * @throws {Error} If the property is not writable.
354 */
355 mockImplementation(value) {
356 if (!this.#descriptor.writable) {
357 throw new ERR_INVALID_ARG_VALUE(
358 'propertyName', this.#propertyName, 'cannot be set',
359 );
360 }
361 const nextValue = this.#getAccessValue(value);
362 const access = {
363 __proto__: null,
364 type: 'set',
365 value: nextValue,
366 // eslint-disable-next-line no-restricted-syntax
367 stack: new Error(),
368 };
369 ArrayPrototypePush(this.#accesses, access);
370 this.#value = nextValue;
371 }
372
373 #getAccessValue(value) {
374 const accessIndex = this.#accesses.length;

Callers

nothing calls this directly

Calls 1

#getAccessValueMethod · 0.95

Tested by

no test coverage detected