{"id":"776fa24876f82138","repo":"jestjs/jest","slug":"no-property-name-supplied","errorCode":null,"errorMessage":"No property name supplied","messagePattern":"No property name supplied","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-jasmine2/src/jasmine/spyRegistry.ts","lineNumber":163,"sourceCode":"        restoreObjectToOriginalState: restoreStrategy,\n      } as Spy);\n\n      obj[methodName] = spiedMethod;\n\n      return spiedMethod;\n    };\n\n    this._spyOnProperty = function (obj, propertyName, accessType = 'get') {\n      if (!obj) {\n        throw new Error(\n          getErrorMsg(\n            `could not find an object to spy upon for ${propertyName}`,\n          ),\n        );\n      }\n\n      if (!propertyName) {\n        throw new Error(getErrorMsg('No property name supplied'));\n      }\n\n      let descriptor: PropertyDescriptor | undefined;\n      try {\n        descriptor = Object.getOwnPropertyDescriptor(obj, propertyName);\n      } catch {\n        // IE 8 doesn't support `definePropery` on non-DOM nodes\n      }\n\n      if (!descriptor) {\n        throw new Error(getErrorMsg(`${propertyName} property does not exist`));\n      }\n\n      if (!descriptor.configurable) {\n        throw new Error(\n          getErrorMsg(`${propertyName} is not declared configurable`),\n        );\n      }","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-jasmine2/src/jasmine/spyRegistry.ts#L145-L181","documentation":"Thrown by `SpyRegistry._spyOnProperty` in spyRegistry.ts:163 when `propertyName` is falsy. The registry needs an explicit property name string to look up the descriptor via `Object.getOwnPropertyDescriptor`.","triggerScenarios":"Calling `spyOnProperty(obj)` with one arg, `spyOnProperty(obj, undefined, 'get')`, or `spyOnProperty(obj, missingVar, 'get')`.","commonSituations":"Typo in a dynamic property name variable; refactor dropping the second arg; misremembering the `spyOnProperty(obj, name, accessType)` arity.","solutions":["Supply the property name as a string literal: `spyOnProperty(obj, 'prop', 'get')`.","If dynamic, assert the variable is a non-empty string before spying.","Remember the arity: object, name, and access type ('get'|'set')."],"exampleFix":"// before\nspyOnProperty(config, undefined, 'get')\n// after\nspyOnProperty(config, 'baseUrl', 'get')","handlingStrategy":"validation","validationCode":"if (typeof propertyName !== 'string' || !propertyName) { throw new TypeError('spyOnProperty needs a property name'); }\nspyOnProperty(obj, propertyName, 'get');","typeGuard":"const isPropName = (s: unknown): s is string => typeof s === 'string' && s.length > 0;","tryCatchPattern":null,"preventionTips":["Remember spyOnProperty arity: (object, propertyName, accessType).","Use string literals for property names."],"tags":["jasmine2","spy","spy-on-property","missing-argument"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}