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

Method setter

lib/internal/test_runner/mock/mock.js:604–630  ·  view source on GitHub ↗

* Mocks a setter method of an object. * This function is a syntax sugar for MockTracker.method with options.setter set to true. * @param {object} object - The target object. * @param {string} methodName - The setter method to be mocked. * @param {Function} [implementation] - An optional

(
    object,
    methodName,
    implementation = kDefaultFunction,
    options = kEmptyObject,
  )

Source from the content-addressed store, hash-verified

602 * @returns {ProxyConstructor} The mock method tracker.
603 */
604 setter(
605 object,
606 methodName,
607 implementation = kDefaultFunction,
608 options = kEmptyObject,
609 ) {
610 if (implementation !== null && typeof implementation === 'object') {
611 options = implementation;
612 implementation = kDefaultFunction;
613 } else {
614 validateObject(options, 'options');
615 }
616
617 const { setter = true } = options;
618
619 if (setter === false) {
620 throw new ERR_INVALID_ARG_VALUE(
621 'options.setter', setter, 'cannot be false',
622 );
623 }
624
625 return this.method(object, methodName, implementation, {
626 __proto__: null,
627 ...options,
628 setter,
629 });
630 }
631
632 module(specifier, options = kEmptyObject) {
633 emitExperimentalWarning('Module mocking');

Callers 2

post-message.jsFile · 0.80

Calls 1

methodMethod · 0.95

Tested by

no test coverage detected