I want to simulate a user touching an element and moving it. But I don't quite get what is document says.
A touch pointer only exists while the screen is touched and receives a new pointerId every time. For these pointers, we use the "button" name from the press action as pointerName.
https://testing-library.com/docs/user-event/pointer#moving-a-pointer
pointer([
// touch the screen at element1
{keys: '[TouchA>]', target: element1},
// move the touch pointer to element2
{pointerName: 'TouchA', target: element2},
// release the touch pointer at the last position (element2)
{keys: '[/TouchA]'},
])
Why there is an A
in the key name TouchA
? and should the following pointerName
use the same name as the key name? Can I use other names for simulating a "touch and move" behavior?
CodePudding user response:
As per documentation, The pointer API allows to simulate interactions with pointer devices. As of now, supported pointer devices are mouse and touch and following pointer input keys are supported
yes, following pointer name would be following the same key name. So basically, when you touch a screen on element one then we assign pointer Input touchA and target is element1. When we move same touch point to element2 which means the pointer name is same touchA but the target is changed to element2 and when the touch ends then [/TouchA] is used.