为什么 @testing-library/user-event 不能与输入元素交互?
我做了一个小仓库来演示我的问题: https://github.com/ msawatzky75/user-event-input-test
我在这里有一些不同的场景:
- 复选框的html 按钮
- 带有点击处理程序
- div 以及带有数据绑定的数据绑定,该
- 输入会在每次输入
每个触发器 时触发由 msw
处理的获取请求。我还设置了 2 个不同的 DOM 环境来运行这些测试:jsdom
和 happy-dom
。
只有与输入元素(复选框和文本输入)交互的测试会失败,并且结果在 DOM 环境中保持一致。
这里有什么问题呢?这是 @testing-library/user-event
的错误吗?如果没有,如何解决这个问题?
i've made a small repo to demontstrate my issue: https://github.com/msawatzky75/user-event-input-test
i have a few different scenarios here:
- html button
- div with click handler
- checkbox with data-binding that is watched
- input that triggers every time its typed into
each of these triggers a fetch request that is handled by msw
. i have also setup 2 different DOM environments to run these tests in: jsdom
and happy-dom
.
only the tests that interact with input elements (checkbox and the text input) fail and the results are consistant across DOM environments.
What is the issue here? is it a bug with @testing-library/user-event
? if not, how could one go about fixing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里的问题是如何渲染组件。更具体地说,如何将其连接到文档主体上。
the original render is as follows:
the
attachTo
property seems to misbehave, but is resovled by doing this instead:this brings the number of passing tests in this example from 4/8 to 7/8, with only Happy-Dom复选框测试失败。
The issue here is how the component is rendered. More specifically, how it is attached to the document body.
the original render is as follows:
the
attachTo
property seems to misbehave, but is resovled by doing this instead:this brings the number of passing tests in this example from 4/8 to 7/8, with only the happy-dom checkbox test failing.