Skip to content

Add ability to fake date in jest tests or make fakeAsync work with jest.useFakeTimers('modern') and jest.setSystemTime #38851

@shairez

Description

@shairez

🚀 feature request

Relevant Package

This feature request is for zone.js

Description

I want to use fake dates in my jest tests (just like jasmine.clock), while using fakeAsync when I'm testing async functions.

A recent addition to jest is the modern fake timers, which uses Sinon's fake timers that allows (among other things) to fake date.now.

Describe the solution you'd like

I think we should write a patch for jest's useFakeTimers, or add the ability to fake the date natively in zone (by exposing FakeDate somehow and manipulating it).

Describe alternatives you've considered

I wrote it in the section above - 2 ways to solve this problem - patch jest's setSystemTime or expose a way to set a fake date manually by zone.js

Thanks!

Metadata

Metadata

Assignees

Labels

area: testingIssues related to Angular testing features, such as TestBedarea: zonesIssues related to zone.jsfeatureIssue that requests a new feature

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions