Closed
Description
Describe the bug
Using jest.useFakeTimers('modern');
in any spec file, causes the tests to fail due to timeout error:
Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 5000 ms timeout specified by jest.setTimeout.
Downgrading to 1.14 fixes this, therefore I believe this is related to 2.x.
I am using jest.useFakeTimers('modern');
in order to call jest.setSystemTime
in my test just FYI.
Expected behavior
Tests should pass
Steps to Reproduce
Simple component:
import React from 'react';
import { Text } from 'react-native';
const TestComponent = () => (
<Text>hello world!</Text>
);
export default TestComponent;
spec file:
import React from 'react';
import { render } from 'react-native-testing-library';
import TestComponent from 'src/components/TestComponent';
jest.useFakeTimers('modern');
describe('TestComponent', () => {
it('should render hello world!', () => {
const utils = render(<TestComponent />);
expect(utils.getByText('hello world!')).not.toBeNull();
});
});
Versions
react: 16.13.1 => 16.13.1
react-native: 0.62.2 => 0.62.2
react-native-testing-library: ^2.1.0 => 2.1.0
react-test-renderer: ^16.13.0 => 16.13.1