Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: modern jest timers #397

Merged
merged 6 commits into from Jul 10, 2020
Merged

fix: modern jest timers #397

merged 6 commits into from Jul 10, 2020

Conversation

thymikee
Copy link
Member

@thymikee thymikee commented Jun 22, 2020

Summary

Fixes #391

Test plan

Added regression tests.

src/__tests__/auto-cleanup.js Outdated Show resolved Hide resolved
src/__tests__/waitFor.test.js Outdated Show resolved Hide resolved
src/flushMicroTasks.js Outdated Show resolved Hide resolved
src/flushMicroTasks.js Outdated Show resolved Hide resolved
@thymikee thymikee marked this pull request as ready for review July 10, 2020 14:03
Copy link
Member

@mdjastrzebski mdjastrzebski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

src/__tests__/auto-cleanup-skip.test.js Outdated Show resolved Hide resolved
Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
@thymikee thymikee merged commit 111b1c9 into master Jul 10, 2020
@thymikee thymikee deleted the fix/timers-modern branch July 30, 2020 14:30
@pke
Copy link
Contributor

pke commented Nov 19, 2020

I wanted to report, that modern fake timers still (again?) don't work in @testing-library/react-native@7.1.0
When enabled all tests run into timeouts.

test("renders greeting depending on time", () => {
  jest.useFakeTimers("modern")
  jest.setSystemTime(new Date("2020-11-19T09:00:00.000+01:00"))
  const { getByText } = render(<Greeting/>)
  expect(getByText("Good day)).toBeTruthy()
})

Uncommenting the first 2 lines in the test make it work (but now always pass due to its dependency on current time).

@thymikee
Copy link
Member Author

@pke we're aware of the issue and tracking it here: #506 Feel free to help reviewing and testing the ongoing work: #568 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Version 2.x not compatible with jest.useFakeTimers('modern');
3 participants