{"id":"44a6e94e48a25893","repo":"jestjs/jest","slug":"propertyname-property-does-not-exist","errorCode":null,"errorMessage":"${propertyName} property does not exist","messagePattern":"(.+?) property does not exist","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-jasmine2/src/jasmine/spyRegistry.ts","lineNumber":174,"sourceCode":"          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      }\n\n      if (!descriptor[accessType]) {\n        throw new Error(\n          getErrorMsg(\n            `Property ${propertyName} does not have access type ${accessType}`,\n          ),\n        );\n      }\n\n      if (obj[propertyName] && isSpy(obj[propertyName])) {\n        if (this.respy) {","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/jestjs/jest/blob/f49721c78e195558b40913977c9230f5b7f559d8/packages/jest-jasmine2/src/jasmine/spyRegistry.ts#L156-L192","documentation":"Thrown by `SpyRegistry._spyOnProperty` in spyRegistry.ts:174 when `Object.getOwnPropertyDescriptor(obj, propertyName)` returns undefined. The property must exist as an own descriptor (or be resolvable) for jasmine to redefine it.","triggerScenarios":"Calling `spyOnProperty(obj, 'missing', 'get')` where the property does not exist on the object; spying on a symbol-keyed property with the wrong name; the property is inherited and has no own descriptor.","commonSituations":"Renaming a getter without updating tests; spying on an instance when the getter lives on the prototype (must spy on the prototype); library version that removed the property.","solutions":["Verify the property exists: `Object.getOwnPropertyDescriptor(obj, 'name')`.","If inherited, spy on the prototype that defines it: `spyOnProperty(Proto.prototype, 'name', 'get')`.","After an upgrade, confirm the property still exists in the new version."],"exampleFix":"// before\nspyOnProperty(instance, 'cachedValue', 'get') // lives on prototype\n// after\nspyOnProperty(Proto.prototype, 'cachedValue', 'get')","handlingStrategy":"validation","validationCode":"if (!Object.getOwnPropertyDescriptor(obj, propertyName)) { throw new Error(`${propertyName} has no own descriptor`); }\nspyOnProperty(obj, propertyName, 'get');","typeGuard":"const hasOwnDescriptor = (o: object, p: string): boolean =>\n  Boolean(Object.getOwnPropertyDescriptor(o, p));","tryCatchPattern":null,"preventionTips":["Spy on the prototype when the property is inherited.","Re-verify property existence after library upgrades."],"tags":["jasmine2","spy","spy-on-property","missing-property","descriptor"],"analyzedSha":"f49721c78e195558b40913977c9230f5b7f559d8","analyzedAt":"2026-08-03T20:16:28.571Z","schemaVersion":2}