jest-expo with waitFor and modern timers

When using the jest-expo preset. I can’t seem to get modern timers to work with waitfor. Without the preset, it appears to work. Also it has been fixed with @testing-library/react-native as well, but the fix they have for the timer does not appear to work.

For example:

  it("should work when starting at zero seconds", async () => {
      .setSystemTime(new Date('2020-01-01T00:00:00Z').getTime());

    const { getByTestId } = render(<MyComponent />)
    await waitFor(() => {
      expect(getByTestId("test").textContent).toEqual(new Date('2020-01-01T00:00:00Z').getTime().toString());
   // hangs at this point then does not complete the test.

For the time being I hacked up a solution with jest.config.js

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.