testing-library/preact-testing-library

touch events (onTouchEnter) do not work in jest jsdom

rburgst opened this issue · 3 comments

  • preact-testing-library version: 2.0.1
  • preact version: 10.7.0
  • node version: 16.14.2
  • npm (or yarn) 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.

anyone home

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.

:tada: This issue has been resolved in version 3.0.2 :tada:

The release is available on:

Your semantic-release bot 📦🚀