How do I programmatically create a TouchEvent in Chrome 41?

前端 未结 4 514
一整个雨季
一整个雨季 2020-12-16 18:21

I am trying to create a touch event for a unit test. After reading https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent, I expected that I would be able to do:

4条回答
  •  被撕碎了的回忆
    2020-12-16 19:04

    It looks like

    document.createEvent('TouchEvent'); 
    

    works if you are using an actual mobile device or mobile emulation.

提交回复
热议问题