question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using something from testing library causes warning: Jest did not exit one second after the test run has completed.

See original GitHub issue

Describe the bug

When I import and using something from @testing-library/react-native the following warning appears:

Jest did not exit one second after the test run has completed.

Expected behavior

This warning does not appear

Steps to Reproduce

Just import render and use it in a test:

import React from 'react';
import { Text } from 'react-native';

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

it('testing library working', () => {
  const { getByText } = render(<Text>123</Text>);

  const text = getByText(/123/);
  expect(text).toBeTruthy();
});

Screenshots

Screenshot 2022-05-23 at 10 40 41 Screenshot 2022-05-23 at 09 35 03

Versions

npmPackages:
    @testing-library/react-native: ^9.1.0 => 9.1.0 
    react: ^17.0.2 => 17.0.2 
    react-native: ^0.67.3 => 0.67.4 
    react-test-renderer: ^17.0.2 => 17.0.2

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:5
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
jamesL92commented, Jun 17, 2022

I was about to say - downgrading Jest to 27.5.1 seems to have fixed it for me.

I still feel like this issue should be reopened though, feels like there’s something in the way @testing-library/react-native methods operate that cause this to be an issue in jest v28+.

2reactions
dennis-gonzalescommented, Aug 5, 2022

I am using Expo and I got the same error. I solved it by using Jest version compatible to Expo (in my case 26.x). The error occurred when I was using Jest 28.x

Can confirm that downgrading to the version that expo supports fixed the issue for me. Command I used fyr

expo install jest -- -D
Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest did not exit one second after the test run has completed ...
Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren't stopped...
Read more >
Jest did not exit one second after the test run has completed.
Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren't stopped...
Read more >
Testing Asynchronous Code · Jest
When you have code that runs asynchronously, Jest needs to know when the code it is testing has completed, before it can move...
Read more >
Don t run the environment loader twice - Grande Pelle
Jest did not exit one second after the test run has completed when using GitHub Actions and Firebase; Why does my useEffect react...
Read more >
React Testing Library and the “not wrapped in act” Errors
…, unit test has no idea that advancing timers will cause component updates, and you will get the “not wrapped in act” error....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found