touch events (onTouchEnter) do not work in jest jsdom
rburgst opened this issue · 3 comments
rburgst commented
preact-testing-library
version: 2.0.1preact
version: 10.7.0node
version: 16.14.2npm
(oryarn
) version: yarn 1.22.17
Relevant code or config
https://github.com/rburgst/preact-testing-lib-pointer-events-bug
Problem description:
The following does not work
interface TestComponentProps {
onPointerEnter: () => void
onClick: () => void
}
export const TestComponent : FunctionComponent<TestComponentProps> = ({onPointerEnter, onClick}) => {
return <div onPointerEnter={onPointerEnter} onClick={onClick} data-testid="test-div">My Div</div>
}
and the corresponding test
interface TestComponentProps {
onPointerEnter: () => void
onClick: () => void
}
export const TestComponent : FunctionComponent<TestComponentProps> = ({onPointerEnter, onClick}) => {
return <div onPointerEnter={onPointerEnter} onClick={onClick} data-testid="test-div">My Div</div>
}
The problem appears that the listeners in jsdom are registered with PointerEnter
while the event being fired is pointerenter
.
Reproduction repository:
https://github.com/rburgst/preact-testing-lib-pointer-events-bug
Suggested solution:
It looks to me as if the listeners in jsdom should be registered all lowercase.
rburgst commented
anyone home
mikerob215 commented
It looks like a temporary fix would be to fire off the event manually like: fireEvent(div, new Event('PointerEnter'))
. I'm looking into making a fix in the library.
github-actions commented
:tada: This issue has been resolved in version 3.0.2 :tada:
The release is available on:
Your semantic-release bot 📦🚀