React测试库不是解析JSON

发布于 2025-01-28 14:35:06 字数 308 浏览 4 评论 0原文

我有一个Textarea组件,可以将JSON {“ SomeKey”:“ SomeValue”}。当我检查DOM时,{“ somekey”:“ someValue”}在检查员中显示得很好。

但是,当我尝试React测试库时,RTL认为TextArea似乎包含“ [对象对象]”,不可解析。

任何洞察力

  1. 关于RTL为什么将此JSON解释为“ [对象对象]”
  2. 我如何测试它的 ?我想断言我输入的价值在那里

I have a TextArea component that takes JSON {"someKey": "someValue"}. When I inspect the dom, {"someKey": "someValue"} shows up just fine in the inspector.

However, when I try react testing library, RTL thinks the TextArea seems to contain "[object Object]" which isn't JSON parseable.

Any insight into

  1. Why RTL is interpreting this json as "[object Object]"
  2. How I can test it? I'd like to assert the value I typed in is there

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文