question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make maxLoops for fake timers configurable

See original GitHub issue

🚀 Feature Proposal

I’d like to be able to configure maxLoops (see https://github.com/facebook/jest/blob/master/packages/jest-fake-timers/src/jestFakeTimers.ts#L88) myself when using jest.useFakeTimers()

Motivation

I am writing a timer app, which actually may count to more than 100.000ms and it would still make sense. Unable to test this though to this limitation.

Pitch

The line already expects an argument which seems to be able to come from somewhere, but the API isn’t making this really publically accessible. I don’t see a reason why this should not be an optional param in jest.useFakeTimers().

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mxmzbcommented, Apr 2, 2019

As a current workaround, it is possible to stack jest.advanceTimersByTime(), e.g.

jest.advanceTimersByTime(100000);
jest.advanceTimersByTime(100000);

Also, weirdly enough, the number in the code (https://github.com/facebook/jest/blob/master/packages/jest-fake-timers/src/jestFakeTimers.ts#L88) says 100000 but you actually hit the limit at 1000000.

0reactions
github-actions[bot]commented, May 6, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Fake Timers
When using fake timers, you need to remember to restore the timers after your test runs. The main reason to do that is...
Read more >
Timer Mocks
In the following example we enable fake timers by calling jest. ... To do this, we're going to use Jest's timer control APIs...
Read more >
Features :: The Sipwise NGCP Handbook - PRO/CARRIER
System-level configuration enables the peer probing feature in general on the Sipwise C5 and determines the operational parameters, such as timeouts, the SIP ......
Read more >
Fake timers - Sinon.JS
Fake timers are synchronous implementations of setTimeout and friends that Sinon.JS can overwrite the global functions with to allow you to more easily...
Read more >
REACT™ Real-Time Programmer's Guide - irix7.com
IRIX Admin: System Configuration and Operation (007-2859-001) ... Memory-mapping makes I/O programming simple, especially when large numbers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found