aryella-lacerda / react-native-accessibility-engine

Make accessibility-related assertions on React Native code using React Test Renderer
MIT License
165 stars 13 forks source link

Jest unable to exit properly because of open handle #315

Open pke opened 1 year ago

pke commented 1 year ago

Describe the bug Jest can not exit because of an open handle created by importing this lib (as described in the README).

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

  ●  MESSAGEPORT

      17 | import mockRNDeviceInfo from "react-native-device-info/jest/react-native-device-info-mock"
      18 | import tempWrite from "temp-write"
    > 19 | import "react-native-accessibility-engine"
         | ^
      20 |
      21 | jest.mock("react-native/Libraries/Linking/Linking", () => ({
      22 |   openURL: jest.fn().mockResolvedValue(),

      at node_modules/scheduler/cjs/scheduler.development.js:178:17
      at Object.<anonymous> (node_modules/scheduler/cjs/scheduler.development.js:645:5)
      at Object.<anonymous> (node_modules/scheduler/index.js:6:20)
      at node_modules/react-test-renderer/cjs/react-test-renderer.development.js:19:19
      at Object.<anonymous> (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:17382:5)
      at Object.<anonymous> (node_modules/react-test-renderer/index.js:6:20)
      at Object.<anonymous> (node_modules/react-native-accessibility-engine/lib/commonjs/engine/index.tsx:2:1)
      at Object.<anonymous> (node_modules/react-native-accessibility-engine/lib/commonjs/matchers/toBeAccessible.ts:2:1)
      at Object.<anonymous> (node_modules/react-native-accessibility-engine/lib/commonjs/matchers/index.ts:1:1)
      at Object.<anonymous> (node_modules/react-native-accessibility-engine/lib/commonjs/index.ts:1:1)
      at Object.<anonymous> (src/setupJest.js:19:1)

Expected behavior

Expect jest to be able to exit properly.

Context

morganick commented 1 year ago

@pke We ran into the same issue and even though running yarn test --detectOpenHandles --no-cache pointed to this library as the issue. We ran into it when we wanted to mock RN Reanimated for Jest. (https://docs.swmansion.com/react-native-reanimated/docs/guides/testing#setup)

It was a combination of two things for me:

Hope this helps!

pke commented 8 months ago

@morganick you mean useEffect in your code?