Skip to content
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

Test fails because new isPointerEventEnabled prevents handler from getting called #699

Closed
ccfz opened this issue Mar 15, 2021 · 3 comments
Closed

Comments

@ccfz
Copy link

ccfz commented Mar 15, 2021

Describe the bug

After upgrading from 0.71 to 0.72 one of my test fails because fireEvent no longer triggers the event. If I disable the new isPointerEventEnabled check the test passes again.

Steps to Reproduce

I am mocking react-native-maps like so:

/* eslint-disable no-shadow, max-classes-per-file */
const React = jest.requireActual('react');
const MapView = jest.requireActual('react-native-maps');
/* eslint-enable no-shadow */

const mockShowCallout = jest.fn();

// eslint-disable-next-line react/prefer-stateless-function, react/no-multi-comp
class MockMarker extends React.Component {
  constructor(props) {
    super(props);

    this.showCallout = mockShowCallout;
  }

  render() {
    const { children } = this.props;

    return React.createElement('Marker', this.props, children);
  }
}

// eslint-disable-next-line react/prefer-stateless-function, react/no-multi-comp
class MockMapView extends React.Component {
  static PROVIDER_GOOGLE = 'google';

  render() {
    const { children } = this.props;

    return React.createElement('MapView', this.props, children);
  }
}

MockMarker.propTypes = MapView.Marker.propTypes;
MockMapView.propTypes = MapView.propTypes;
MockMapView.Marker = MockMarker;
MockMapView.Callout = MapView.Callout;
MockMapView.exposedMarkerShowCallout = mockShowCallout;

module.exports = MockMapView;

The MapView implements the event onRegionChangeComplete which is what I trigger in the test like so:
fireEvent(wrapper.UNSAFE_getByType(RNMapView), 'RegionChangeComplete');

Screenshots

Versions

    @testing-library/react-native: ^7.2.0 => 7.2.0 
    react: 17.0.1 => 17.0.1 
    react-native: 0.63.4 => 0.63.4 
    react-test-renderer: ^17.0.1 => 17.0.1 
@thymikee
Copy link
Member

Would you like to investigate this a little more and contribute a fix maybe? :)

@mdjastrzebski
Copy link
Member

@ccfz could you verify that the issue you reported does still occur on the latest version of RNTL (& React Native, React, React Test Renderer). If so, could you please provide repro repository hopefully based on ours examples/basic app in our repo.

@mdjastrzebski
Copy link
Member

It seems that it should be fixed by #906, which restricted pointer checks just to press event.

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

No branches or pull requests

3 participants