{"record":{"id":"7017aa5c099fc65f","repo":"jestjs/jest","slug":"property-string-propertykey-does-not-exist-i","errorCode":null,"errorMessage":"Property `${String(propertyKey)}` does not exist in the provided object","messagePattern":"Property `(.+?)` does not exist in the provided object","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-mock/src/index.ts","lineNumber":1386,"sourceCode":"    object: T,\n    propertyKey: keyof T,\n    accessType: 'get' | 'set',\n  ): MockInstance {\n    const isPropertyOwner = Object.prototype.hasOwnProperty.call(\n      object,\n      propertyKey,\n    );\n\n    let descriptor = Object.getOwnPropertyDescriptor(object, propertyKey);\n    let proto = Object.getPrototypeOf(object);\n\n    while (!descriptor && proto !== null) {\n      descriptor = Object.getOwnPropertyDescriptor(proto, propertyKey);\n      proto = Object.getPrototypeOf(proto);\n    }\n\n    if (!descriptor) {\n      throw new Error(\n        `Property \\`${String(\n          propertyKey,\n        )}\\` does not exist in the provided object`,\n      );\n    }\n\n    if (!descriptor.configurable) {\n      throw new Error(\n        `Property \\`${String(propertyKey)}\\` is not declared configurable`,\n      );\n    }\n\n    if (!descriptor[accessType]) {\n      throw new Error(\n        `Property \\`${String(\n          propertyKey,\n        )}\\` does not have access type ${accessType}`,\n      );","sourceCodeStart":1368,"sourceCodeEnd":1404,"githubUrl":"https://github.com/jestjs/jest/blob/8e6d128e4a278059ecddecaa97400b04c8ae5fd9/packages/jest-mock/src/index.ts#L1368-L1404","documentation":"Thrown by the internal _spyOnProperty (reached when spyOn is called with a third 'get'/'set' accessType) when no property descriptor is found anywhere on the object or its prototype chain. The accessor-based spy needs an existing descriptor to replace.","triggerScenarios":"jest.spyOn(obj,'missing','get'); jest.spyOn(obj,'noAccessor','set') where the property does not exist on obj or any prototype.","commonSituations":"Misspelled accessor name; the accessor is defined on a different prototype level than expected; the property is a plain value (no get/set) so the descriptor has no accessor to spy on via this path.","solutions":["Confirm the property exists with Object.getOwnPropertyDescriptor and walk the prototype chain.","If it is a plain value, drop the accessType and use plain spyOn or jest.replaceProperty.","Spy on the prototype object that actually defines the accessor."],"exampleFix":"// before\njest.spyOn(obj, 'value', 'get'); // no such accessor\n// after\nconst desc = Object.getOwnPropertyDescriptor(obj, 'value');\nif (desc?.get) jest.spyOn(obj, 'value', 'get');\nelse jest.replaceProperty(obj, 'value', newValue);","handlingStrategy":"validation","validationCode":"const desc = Object.getOwnPropertyDescriptor(obj, propertyKey)\n  ?? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(obj), propertyKey);\nif (!desc) {\n  throw new Error(`No descriptor for ${String(propertyKey)}; not an accessor`);\n}\njest.spyOn(obj, propertyKey, accessType);","typeGuard":"const hasAccessorDescriptor = (o: object, k: PropertyKey): boolean => {\n  let d = Object.getOwnPropertyDescriptor(o, k);\n  let p = Object.getPrototypeOf(o);\n  while (!d && p !== null) { d = Object.getOwnPropertyDescriptor(p, k); p = Object.getPrototypeOf(p); }\n  return !!d && (!!d.get || !!d.set);\n};","tryCatchPattern":null,"preventionTips":["Walk the prototype chain when verifying accessors.","Use plain spyOn for non-accessor methods.","Inspect the descriptor before choosing the accessType overload."],"tags":["spy","mock","accessor","missing-property"],"backgroundTag":null,"analyzedSha":"8e6d128e4a278059ecddecaa97400b04c8ae5fd9","analyzedAt":"2026-08-10T18:11:27.960Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}