Skip to content

Can not test fireEvent.touchStart side effects #23

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
jottaxwds opened this issue Mar 27, 2020 · 1 comment · Fixed by #57
Closed

Can not test fireEvent.touchStart side effects #23

jottaxwds opened this issue Mar 27, 2020 · 1 comment · Fixed by #57
Labels

Comments

@jottaxwds
Copy link

  • preact-testing-library version: 1.0.2
  • preact version: 10.3.2
  • node version: 13.9.0
  • npm (or yarn) version: 6.13.7

Relevant code or config
Button.js

const Button = ({myHandler}) => (
    <button data-testid='my-button' onTouchStart={myHandler}>Click me</button>
)

export default Button;

Button.test.js

import { render, fireEvent } from '@testing-library/preact';
import Button from './Button';

describe('Button behavior test:', () => {
   it('Should call myHandler on touchStart', () => {
        const mockFn = jest.fn();
        const { getByTestId } = render(<Button myHandler={mockFn} />);
        fireEvent.touchStart(getByTestId('my-button'));
        expect(mockFn).toHaveBeenCalled();
   });
});

What you did:
Simple button component with onTouchStart event that triggers a prop method.

What happened:
I can not test it due to fireEvent.touchStart is not triggering the event and not creating side effects on my component.

Problem description:
I need to unit test the side effects of onTouchStart / onTouchEnd events on my components.

@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
1 participant