【发布时间】:2016-12-22 01:48:21
【问题描述】:
我试过了:
input.simulate('blur');
和
input.simulate('onBlur');
这些都不起作用。这在 Enzyme 中是否可用(我使用的是 2.4.1 版)。
【问题讨论】:
-
我以前用过
simulate('blur');,效果很好。
标签: unit-testing reactjs frontend enzyme
我试过了:
input.simulate('blur');
和
input.simulate('onBlur');
这些都不起作用。这在 Enzyme 中是否可用(我使用的是 2.4.1 版)。
【问题讨论】:
simulate('blur');,效果很好。
标签: unit-testing reactjs frontend enzyme
input.simulate('focus')、input.simulate('change') 和 input.simulate('blur') 应该可以工作。检查您的 input 是否实际上是声明为 _wrapper.find('input') 的节点并且存在。其次,还有一个类似的问题:Enzyme - How to access and set <input> value?
最后,如果你是check the source code 的ReactWrapper component,那么你会发现它使用了all events that React can recognize。所以错误就在你的代码中。
【讨论】: