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

Lots of warnings logged in tests with fake timers #665

Open
5 of 15 tasks
TuurDutoit opened this issue Jul 22, 2024 · 1 comment
Open
5 of 15 tasks

Lots of warnings logged in tests with fake timers #665

TuurDutoit opened this issue Jul 22, 2024 · 1 comment
Labels
bug Crush'em all.

Comments

@TuurDutoit
Copy link
Contributor

Decision Table

  • My issue does not look like “The HTML attribute 'xxx' is ignored” (unless we claim support for it)
  • My issue does not look like “The HTML element <yyy> is not rendered”

Good Faith Declaration

Description

When using jest.useFakeTimers() in tests, RNRH logs a whole lot of warnings, even when only rendering the component once.

I've also found the root cause. When using the fake timers, Jest patches performance.now() (among others). Crucially, it sets the return value to 0 by default (you can advance this value using jest.advanceTimersByTime() and related utilities, but the default is 0)
Unfortunately, RNRH also uses 0 as the default of the lastUpdate ref (source). Therefore, on the very first render, RNRH thinks the previous render happened exactly 0ms ago, and prints a bunch of warnings!

I realize this is not really a "bug" per se, and definitely won't affect any end users. However, it might confuse other devs like it confused me, and the fix is probably quite simple.

React Native Information

System:
  OS: macOS 14.2.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 1.43 GB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.13.1
    path: /private/var/folders/fk/c9z1tyhj02nfdn9dz_71vjk80000gq/T/xfs-3bfe75a4/node
  Yarn:
    version: 3.2.3
    path: /private/var/folders/fk/c9z1tyhj02nfdn9dz_71vjk80000gq/T/xfs-3bfe75a4/yarn
  npm:
    version: 10.5.2
    path: ~/.local/state/fnm_multishells/1402_1720596864919/bin/npm
  Watchman:
    version: 2024.05.06.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.0
    path: /Users/tuur/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.2 AI-222.4459.24.2221.9862592
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.9
    path: /Users/tuur/.jenv/shims/javac
  Ruby:
    version: 3.0.6
    path: /Users/tuur/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.14
    wanted: 0.72.14
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

RNRH Version

6.3.4

Tested Platforms

  • Android
  • iOS
  • Web
  • MacOS
  • Windows

Reproduction Platforms

  • Android
  • iOS
  • Web
  • MacOS
  • Windows

Minimal, Reproducible Example

#664

Additional Notes

No response

@jsamr
Copy link
Collaborator

jsamr commented Jul 22, 2024

@TuurDutoit Appreciate the excellent submission and reproduction, thank you!

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

No branches or pull requests

2 participants