pointer API allows to simulate interactions with pointer devices. It
accepts a single pointer action or an array of them.
Our primary target audience tests per
jsdomenvironment and there is no layout in
jsdom. This means that different from your browser the elements don't exist in a specific position, layer and size.
We don't try to determine if the pointer action you describe is possible at that position in your layout.
There are two types of actions: press and move.
A pointer action is a press action if it defines a key to be pressed, to be released, or both.
You can declare multiple press actions (on the same position) at once which will
be resolved to multiple actions internally. If you don't need to declare any
other properties you can also just supply the
In order to press a button without releasing it, the button name is suffixed with
For just releasing a previously pressed button, the tag is started with
Which buttons are available depends on the
Every pointer action that is not a press action describes a pointer movement.
You can declare which pointer is moved per
pointerName property. This defaults
Note that the
mouse pointer (
pointerId: 1) is also the only pointer that
always exists and has a position. 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
PointerTarget props allows to describe the position of the pointer on the
coords you provide are applied as-is to the resulting
can be omitted.
target should be the element receiving the pointer input in the browser.
This is the topmost element that can receive pointer event at those coordinates.
Pointer actions can alter the selection in the document.
In the browser every pointer position corresponds with a DOM position. This is a DOM node and a DOM offset which usually translates to the character closest to the pointer position.
As all character in a no-layout environment are in the same layout position we assume a pointer position to be closest to the last descendant of the pointer
If you provide
offset, we assume the pointer position to be closest to the
offset-th character of
If you also provide
node, we treat
offset as the exact DOM
position to be used for any selection.