Cannot read property 'Direction' of undefined, tests only : <p>I just added <code>TouchableOpacity</code> to a component and the app is working fine, but my tests, using <code>react-native-testing-library</code>, fail to run:</p>

<pre class="lang-js prettyprint-override"><code>  ● Test suite failed to run

    TypeError: Cannot read property 'Direction' of undefined

      at Object.Direction (node_modules/react-native-gesture-handler/Directions.js:3:39)
      at Object.&lt;anonymous&gt; (node_modules/react-native-gesture-handler/GestureHandler.js:2:1)
</code></pre>

<p>I just removed and re-added <code>react-native-gesture-handler</code> with yarn, and ran <code>pod install</code>. Again, the app is working, but the tests fail to run.</p>

<p>I actually get the same error when using <code>&lt;Text onPress={() =&gt; onOptionPress(opt)} /&gt;</code> rather than <code>TouchableOpacity</code>.</p>

<p>component: </p>

<pre class="lang-js prettyprint-override"><code>const SelectOptions = ({ field, dismissOverlay, onOptionPress }) =&gt; {
  return (
    &lt;Overlay
      isVisible
      overlayStyle={styles.overlay}
      height={"auto"}
      onBackdropPress={dismissOverlay}
    &gt;
      &lt;View&gt;
        {field.options.map((opt, i) =&gt; (
          &lt;TouchableOpacity
            style={styles.option}
            key={i}
            onPress={() =&gt; onOptionPress(opt)}
          &gt;
            &lt;Text&gt;{opt}&lt;/Text&gt;
          &lt;/TouchableOpacity&gt;
        ))}
      &lt;/View&gt;
    &lt;/Overlay&gt;
  );
};
</code></pre>

<p>test:</p>

<pre class="lang-js prettyprint-override"><code>describe("CardFormView", () =&gt; {
  let wrapper, birthdayField;

  beforeEach(() =&gt; {
    wrapper = render(
      &lt;React.Fragment&gt;
        &lt;CardFormView form={form} /&gt;
      &lt;/React.Fragment&gt;
    );
    birthdayField = wrapper.getByText("Add a Birthday Gift Card");
  });

  const message1 =
    "...";
  const message2 =
    "...";

  it("shows the options for a birthday card when clicked", () =&gt; {
    fireEvent.press(birthdayField);
    expect(wrapper.getByText(message1)).toBeDefined();
  });

  it("sets an option when clicked", () =&gt; {
    fireEvent.press(birthdayField);
    const firstOption = wrapper.getByText(message1);
    fireEvent.press(firstOption);
    expect(wrapper.queryByText(message2)).toBeNull();
    expect(wrapper.getByText(message1)).toBeDefined();
  });
});
</code></pre>
