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

Add advanceDateByTime #9522

Closed
garrettmaring opened this issue Feb 5, 2020 · 2 comments
Closed

Add advanceDateByTime #9522

garrettmaring opened this issue Feb 5, 2020 · 2 comments

Comments

@garrettmaring
Copy link

🚀 Feature Proposal

Jest has a great mocking for timers with useFakeTimers and advanceTimersByTime. It'd be very useful to have a similar set of utilities for setting the global Date.now() and manually advancing it.

Motivation

Testing Date related logic.

Example

An example of code that could be tested with this feature.

export type ElapsedTime = () => number;

export const createElapsedTime = (): ElapsedTime => {
  const mark = Date.now();

  return () => Date.now() - mark;
};

Pitch

Date related code is a central component of many modern applications. Being able to use the Jest ecosystem to test this code properly would expand the region of code that Jest can mock and test well.

@SimenB
Copy link
Member

SimenB commented Feb 5, 2020

Duplicate of #2234, will be solved by #7776

@SimenB SimenB closed this as completed Feb 5, 2020
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants