react-native-testing-library icon indicating copy to clipboard operation
react-native-testing-library copied to clipboard

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

Open paskalov-aris opened this issue 3 years ago • 5 comments

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

paskalov-aris avatar May 23 '22 09:05 paskalov-aris

@paskalov-aris I'm experiencing this exact problem, but with @testing-library/react-hooks. Did you solve this?

sondreluc avatar May 23 '22 15:05 sondreluc

I'm also experiencing the same issue. Would love to know what you did to solve this @paskalov-aris (assuming it was solved that is)

jamesL92 avatar Jun 17 '22 09:06 jamesL92

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

dapicester avatar Jun 17 '22 09:06 dapicester

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+.

jamesL92 avatar Jun 17 '22 13:06 jamesL92

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

dennis-gonzales avatar Aug 05 '22 03:08 dennis-gonzales

This seems to be the same error as #1054.

@dennis-gonzales @jamesL92 @dapicester @sondreluc @paskalov-aris please check if [this fix]((https://github.com/callstack/react-native-testing-library/issues/1054#issuecomment-1221099057) works for you.

mdjastrzebski avatar Aug 19 '22 21:08 mdjastrzebski

@mdjastrzebski Can confirm that it fixes this issue for me 👍

sondreluc avatar Aug 20 '22 06:08 sondreluc