react-native-accessibility-engine
react-native-accessibility-engine copied to clipboard
Jest unable to exit properly because of open handle
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")
@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!
@morganick you mean useEffect
in your code?