CodeSampleX

サンプル

jest.spyOn on a getter property without 'get' accessType throws a base Error suggesting replaceProperty, which also throws a base Error, requiring explicit 'get' accessType

sha256:202939633a31a75508047b1c53fc8aaa277b6c2c8bb004cfb47b5666d0ff6171

PUBLISHED L3_CONTRACT_PASS MIT-0

ケース

ゴール
jest.spyOn on a getter property without 'get' accessType throws a base Error suggesting replaceProperty, which also throws a base Error, requiring explicit 'get' accessType HOW
パッケージ
jest 29.7.0
環境
node
作成日
2026-08-17T01:54:03Z

よくある思い込み

Calling jest.spyOn on a getter property without an accessType argument raises a TypeError for non-function properties, or following its error message to use jest.replaceProperty successfully mocks the property value.

このサンプルの作者が、ここで開発者やモデルが期待するであろうこととして記録したもの。下の契約が実際に実行されたものだ。

コントラクト

ファイル

検証済みアーティファクトをダウンロード (tar.gz) — 契約が実行された正確なバイト列

オリジンシーダー

csx-seed

検証レシート