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

Jest unable to exit properly because of open handle #315

Open
pke opened this issue Jun 28, 2023 · 2 comments
Open

Jest unable to exit properly because of open handle #315

pke opened this issue Jun 28, 2023 · 2 comments
Assignees

Comments

@pke
Copy link
Contributor

pke commented Jun 28, 2023

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

  • React Native version: 0.66.5
  • Test runner: e.g. Jest
  • Accessibility Engine version: 3.2.0 (with "react-test-renderer": "17.0.2")
@morganick
Copy link

@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:

  • useEffect that was setting up events on every render instead of just on the initial render. (Not specifying an empty dependency array.)
  • Upgrading jest because there were regressions that were introduced and fixed in >= 29.6.3 (https://github.com/jestjs/jest/releases/tag/v29.6.3)

Hope this helps!

@pke
Copy link
Contributor Author

pke commented Feb 23, 2024

@morganick you mean useEffect in your code?

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