Closed
Description
Reproduction example
https://codesandbox.io/s/misty-haze-n45bf4?file=/src/App.js
Prerequisites
<button>Touch me</button>
document.querySelector('button').addEventListener('pointerup', (e) => {
console.log(e.button)
})
await user.pointer({
tags: '[MouseLeft]',
target: document.querySelector('button'),
})
Expected behavior
PointerEvent
sets event.button
and event.buttons
to allow us to figure out which button was used.
https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events#determining_button_states
As an example, if the left mouse button was used, the pointerup
event event.button
is 0
.
Actual behavior
The PointerEvent
created by userEvent.pointer()
does not assign event.button
or event.buttons
, so both are undefined
in a event handler.
This means event handlers using these properties don't work under test.
User-event version
14.0.4
Environment
Testing Library framework:
JS framework:
Test environment:
DOM implementation:
Additional context
No response