-
-
Notifications
You must be signed in to change notification settings - Fork 769
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
useFakeTimers doesn't fake performance.now() #803
Comments
Why would you use Can you give a usage example? |
@mroderick "for timeouts" I've meant when you check if enough time has passed: var started = performance.now();
function calledLater() {
if (performance.now() - started > 5000) {
// do something
}
} In my use case I'm checking if some visual feedback was visible to the user long enough before removing it. Performance.now() guarantees it'll only go forward and it's not possible to break it by adjusting the system clock. I've fixed this for myself by stubbing performance.now() with Date.now() Since posting this I've found that timers are handled by lolex, so probably it's better to move this issue there? |
Why not just use setTimeout(function calledLater(){
// do something
}, 5000); |
It's not an operation that should be run after some time, but a check if sufficient amount of time has passed. |
|
In any case, pull requests to |
I am closing the issue here. If you feel like contributing to |
As using perfomance.now() is more robust for timeouts than Date.now(), it'd be nice if creating a
clock
would "pause" or synchronizeperformance.now
to provided now value and callingclock.tick
would move it.The text was updated successfully, but these errors were encountered: