简体   繁体   English

用酶模拟点击

[英]Simulate click with enzyme

I want to simulate click on x,y target in element. 我想模拟单击元素中的x,y目标。 Enzyme simulate will dispatch react event on target element, but i'm not able to find info on how to modify this event to point at particular location, not element as a whole. 酶模拟将在目标元素上调度react事件,但我无法找到有关如何修改此事件以指向特定位置的信息,而不是整个元素。 Thanks! 谢谢!

enzyme simulate takes a second parameter where you can pass the event object. simulate使用第二个参数,您可以在其中传递事件对象。 For example, I have provided a sample test case for Input box 例如,我为“输入”框提供了一个示例测试用例

   Component.find('input').simulate('change', {
      target: {
        value: 'Text'
      }
    });

Have a look at the enzyme 's documentation here 这里查看enzyme的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM