-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
Do you want to request a feature or report a bug?
bug
What is the current behavior?
When using fake timers, creating a debounced function, calling it a couple times, and then calling jest.runAllTimers, an error will be printed:
Ran 100000 timers, and there are still more! Assuming we've hit an infinite recursion and bailing out...
at FakeTimers.runAllTimers (node_modules/jest-util/build/FakeTimers.js:207:13)
at Object.<anonymous> (__tests__/lodash-bug-test.js:12:8)
It seems that changing the second argument passed to debounce (the time in milliseconds to debounce the function for) changes whether or not this error occurs. For example: on my machine (mid-2014 MBP) it appears to always throw when the delay is above ~600ms, but only fails some of the time when it's around 500ms.
This issue has been encountered before (lodash/lodash#2893), and it seems to have been on Lodash's end. I added a comment to the issue in the Lodash repo, but @jdalton said that he's not sure why it would still be occurring with recent versions of Lodash.
If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.
https://github.com/rimunroe/lodash-jest-timer-issue
What is the expected behavior?
The calling jest.runAllTimers should cause the debounced function to behave as though the time it was told to debounce for elapsed.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
I'm using macOS 10.12.4
No configuration other than calling jest.runAllTimers in the test.
I encountered the bug with the following versions:
- node@4.4.7 with npm@2.15.8
- node@6.10.3 with npm@4.2.0 and yarn@0.23.4
- jest@18.1.0
- jest@19.0.1
- lodash@4.17.4