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

I get the open handle warning with Jest 28. Jest 27 doesn't have the same problem. #1283

Closed
BigboNorth opened this issue Jan 18, 2023 · 1 comment

Comments

@BigboNorth
Copy link

I get the open handle warning with Jest 28. Jest 27 doesn't have the same problem.

Test:

import { render } from '@testing-library/react-native'
import React from 'react'
import { Text } from 'react-native'

describe('a test', () => {
  it('can run a test', () => {
    const { getByText } = render(<Text>Hello</Text>)

    expect(getByText('Hello')).toBeDefined()
  })
})

Test output:

 PASS  services/meow.spec.tsx
  weird test
    ✓ can run a test (19 ms)

--------------|---------|----------|---------|---------|-------------------
File          | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------|---------|----------|---------|---------|-------------------
All files     |       0 |      100 |     100 |       0 |
 .eslintrc.js |       0 |      100 |     100 |       0 | 1
--------------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        1.901 s, estimated 4 s
Ran all test suites matching /services\/meow.spec.ts/i.

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

  ●  MESSAGEPORT

    > 1 | import { render } from '@testing-library/react-native'
        | ^
      2 | import React from 'react'
      3 | import { Text } from 'react-native'
      4 |

      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/@testing-library/react-native/src/act.ts:1:1)
      at Object.<anonymous> (node_modules/@testing-library/react-native/src/pure.ts:1:1)
      at Object.<anonymous> (node_modules/@testing-library/react-native/src/index.ts:1:1)
      at Object.<anonymous> (services/meow.spec.tsx:1:1)

Dependencies (at least the ones that matter, I hope):

  "dependencies": {
    "@react-navigation/bottom-tabs": "^6.3.1",
    "@react-navigation/native": "^6.0.10",
    "@react-navigation/native-stack": "^6.6.2",
    "expo": "~45.0.0",
    "react": "17.0.2",
},
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/plugin-proposal-async-generator-functions": "^7.18.6",
    "@babel/plugin-proposal-export-namespace-from": "^7.17.12",
    "@react-native-community/eslint-config": "^3.0.2",
    "@testing-library/dom": "^8.13.0",
    "@testing-library/jest-native": "^4.0.5",
    "@testing-library/react-hooks": "^8.0.0",
    "@testing-library/react-native": "^10.1.1",
    "@typescript-eslint/eslint-plugin": "^5.27.1",
    "@typescript-eslint/parser": "^5.27.1",
    "babel-jest": "^28.1.0",
    "isomorphic-fetch": "^3.0.0",
    "jest": "^27",
    "jest-expo": "^45.0.1",
    "jest-junit": "^13.2.0",
    "jest-mock": "^28.1.1",
    "react-test-renderer": "^17.0.2",
    "ts-jest": "^27",
    "typescript": "~4.5",
  },
  "resolutions": {
    "@types/react": "17.0.2",
    "@types/react-dom": "17.0.2",
  },

We're using the jest-expo prese, however, not the React Native one (directly, anyways).

Originally posted by @duraz0rz in #1007 (comment)

@mdjastrzebski
Copy link
Member

@BigboNorth this is a known issue with React 17. See workaround here. Migrating to React 18 should resolve the issue.

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

2 participants