Skip to content
This repository was archived by the owner on Jul 30, 2020. It is now read-only.
This repository was archived by the owner on Jul 30, 2020. It is now read-only.

View's 'measure' method callback not invoked #125

Closed
@abmantis

Description

@abmantis
  • react-native or expo: expo 37.0.3
  • native-testing-library version: 5.0.3
  • jest-preset: @testing-library/react-native/jest-preset
  • react-native version: 37.0.1
  • node version: 14.2.0

Relevant code or config:

  function onPress() {
    cardView.current.measure((x, y, width, height, pageX, pageY) => {
      console.log('Measure called', pageX, pageY, width, height);
    });
  }

What you did:

Calling fireEvent.press on a button my component, that calls the onPress() callback I posted above.
When running normally on the browser, pressing the button logs "Measure called ....".

What happened:

The measure callback is not invoked, even though the measure method is being called.

Problem description:

My project relies on measure to trigger some user-facing behavior.

Suggested solution:

Too new to React Native and JS in general :/

Can you help us fix this issue by submitting a pull request?

Sure, with some guidance.

EDIT:

I ended up mocking the method myself with the following code, but I was hoping this was not necessary with the native-testing-library preset.

jest.spyOn(View.prototype, 'measureInWindow').mockImplementation((cb) => cb(0, 0, 1, 1));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions