Skip to content

Using Jest mock timers and waitFor together causes tests to timeout #506

Closed
@dcalhoun

Description

@dcalhoun

Describe the bug

Related to #391. Using jest.useFakeTimers() in combination with waitFor, causes the tests using waitFor 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.

Relying upon jest.useFakeTimers("modern") instead causes the above failure for all tests if the file merely imports waitFor at all, regardless if the given test uses waitFor or not.

Expected behavior

All tests in the reproduction test case should pass.

Steps to Reproduce

  1. Clone the reproduction test case.
  2. yarn install
  3. yarn test

Versions

npmPackages:
    @testing-library/react-native: ^7.0.1 => 7.0.1 
    react: ^16.13.1 => 16.13.1 
    react-native: ^0.63.2 => 0.63.2 
    react-test-renderer: ^16.13.1 => 16.13.1

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