Skip to content

touch events (onTouchEnter) do not work in jest jsdom #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rburgst opened this issue Apr 4, 2022 · 3 comments · Fixed by #57
Closed

touch events (onTouchEnter) do not work in jest jsdom #51

rburgst opened this issue Apr 4, 2022 · 3 comments · Fixed by #57
Labels

Comments

@rburgst
Copy link

rburgst commented Apr 4, 2022

  • 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.

@rburgst rburgst changed the title touch events do not work touch events (onTouchEnter) do not work in jest jsdom Apr 4, 2022
@rburgst
Copy link
Author

rburgst commented Apr 11, 2022

anyone home

@mikerob215
Copy link
Contributor

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
Copy link

🎉 This issue has been resolved in version 3.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants