Skip to content

Difference between Node 14 and Node 16 in the basic example #1054

@jensdev

Description

@jensdev

Thank you for this amazing package

Describe the bug

When running when Node v14.17.5, I get the expected result.

➜  basic git:(main) node --version
v14.18.1
➜  basic git:(main) npx jest
 PASS  __tests__/App.test.tsx
  ✓ renders correctly (185 ms)
  ✓ User can sign in successully with correct credentials (281 ms)
  ✓ User will see errors for incorrect credentials (299 ms)
  ✓ User can sign in after incorrect attempt (567 ms)

Test Suites: 1 passed, 1 total
Tests:       4 passed, 4 total
Snapshots:   0 total
Time:        1.763 s, estimated 6 s
Ran all test suites.

But when using Node v16 or higher

➜  basic git:(main) node --version
v16.14.2
➜  basic git:(main) npx jest      
 PASS  __tests__/App.test.tsx
  ✓ renders correctly (189 ms)
  ✓ User can sign in successully with correct credentials (279 ms)
  ✓ User will see errors for incorrect credentials (300 ms)
  ✓ User can sign in after incorrect attempt (569 ms)

Test Suites: 1 passed, 1 total
Tests:       4 passed, 4 total
Snapshots:   0 total
Time:        1.755 s, estimated 2 s
Ran all test suites.
Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue.

When I run it with detectOpenHandles.

➜  basic git:(main) npx jest --detectOpenHandles
 PASS  __tests__/App.test.tsx (7.786 s)
  ✓ renders correctly (4571 ms)
  ✓ User can sign in successully with correct credentials (293 ms)
  ✓ User will see errors for incorrect credentials (299 ms)
  ✓ User can sign in after incorrect attempt (577 ms)

Test Suites: 1 passed, 1 total
Tests:       4 passed, 4 total
Snapshots:   0 total
Time:        7.828 s
Ran all test suites.

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

  ●  MESSAGEPORT

      1 | import * as React from 'react';
    > 2 | import { render, screen, fireEvent } from '@testing-library/react-native';
        | ^
      3 | import App from '../App';
      4 |
      5 | /**

      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> (__tests__/App.test.tsx:2:1)

Am I missing something or should this just work?

Expected behavior

Same output for Node v16 and higher

Steps to Reproduce

Use Node v16 or higher

Screenshots

Versions

➜  basic git:(main) npx envinfo --npmPackages react,react-native,react-test-renderer,@testing-library/react-native

  npmPackages:
    @testing-library/react-native: ^11.0.0 => 11.0.0 
    react: 17.0.2 => 17.0.2 
    react-native: 0.68.2 => 0.68.2 
    react-test-renderer: ^17.0.2 => 17.0.2 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions