{"record":{"id":"12a71e908bdc295c","repo":"jestjs/jest","slug":"property-string-propertykey-does-not-have-ac","errorCode":null,"errorMessage":"Property `${String(propertyKey)}` does not have access type ${accessType}","messagePattern":"Property `(.+?)` does not have access type (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/jest-mock/src/index.ts","lineNumber":1400,"sourceCode":"      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      );\n    }\n\n    const original = descriptor[accessType];\n\n    if (!this.isMockFunction(original)) {\n      if (typeof original !== 'function') {\n        throw new TypeError(\n          `Cannot spy on the ${String(\n            propertyKey,\n          )} property because it is not a function; ${this._typeOf(\n            original,\n          )} given instead.${\n            typeof original === 'object'\n              ? ''","sourceCodeStart":1382,"sourceCodeEnd":1418,"githubUrl":"https://github.com/jestjs/jest/blob/8e6d128e4a278059ecddecaa97400b04c8ae5fd9/packages/jest-mock/src/index.ts#L1382-L1418","documentation":"Thrown by _spyOnProperty when the descriptor exists but lacks the requested accessType — e.g., you asked for 'get' on a write-only setter, or 'set' on a read-only getter. descriptor[accessType] is undefined.","triggerScenarios":"jest.spyOn(obj,'x','get') when x has only a setter; jest.spyOn(obj,'x','set') when x is a read-only getter.","commonSituations":"Guessing the wrong access type; the property's accessor shape differs from what the test assumes after an API change.","solutions":["Inspect the descriptor (Object.getOwnPropertyDescriptor) to see which of get/set exists.","Use the matching accessType ('get' for reads, 'set' for writes).","If only one side exists, spy on that side only."],"exampleFix":"// before\njest.spyOn(store, 'data', 'set'); // store.data has only a getter\n// after\nconst d = Object.getOwnPropertyDescriptor(store, 'data');\njest.spyOn(store, 'data', d?.get ? 'get' : 'set');","handlingStrategy":"validation","validationCode":"const d = Object.getOwnPropertyDescriptor(obj, propertyKey);\nif (!d || !d[accessType]) {\n  throw new Error(`${String(propertyKey)} has no '${accessType}' accessor`);\n}\njest.spyOn(obj, propertyKey, accessType);","typeGuard":"const hasAccessType = (o: object, k: PropertyKey, a: 'get' | 'set'): boolean => {\n  const d = Object.getOwnPropertyDescriptor(o, k);\n  return !!d && typeof d[a] === 'function';\n};","tryCatchPattern":null,"preventionTips":["Inspect the descriptor to learn which side (get/set) exists.","Spy only on the accessType the property actually defines.","Write a small helper that picks the right accessType automatically."],"tags":["spy","mock","accessor"],"backgroundTag":null,"analyzedSha":"8e6d128e4a278059ecddecaa97400b04c8ae5fd9","analyzedAt":"2026-08-10T18:11:27.960Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}