-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
setSystemTime and getRealSystemTime type and doc update #10169
Changes from 4 commits
104a0f2
1e0c624
2a30041
0811af6
87ca8be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
'use strict'; | ||
|
||
test('fake timers', () => { | ||
test('fake timers with number argument', () => { | ||
jest.setSystemTime(0); | ||
|
||
expect(Date.now()).toBe(0); | ||
|
@@ -16,3 +16,13 @@ test('fake timers', () => { | |
|
||
expect(Date.now()).toBe(1000); | ||
}); | ||
|
||
test('fake timers with Date argument', () => { | ||
jest.setSystemTime(new Date(0)); | ||
|
||
expect(Date.now()).toBe(0); | ||
|
||
jest.setSystemTime(1000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this doesn't use a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤦 it does indeed, thank you. |
||
|
||
expect(Date.now()).toBe(1000); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
'use strict'; | ||
|
||
test('fake timers', () => { | ||
test('fake timers with number argument', () => { | ||
jest.useFakeTimers('modern'); | ||
|
||
jest.setSystemTime(0); | ||
|
@@ -18,3 +18,15 @@ test('fake timers', () => { | |
|
||
expect(Date.now()).toBe(1000); | ||
}); | ||
|
||
test('fake timers with Date argument', () => { | ||
jest.useFakeTimers('modern'); | ||
|
||
jest.setSystemTime(new Date(0)); | ||
|
||
expect(Date.now()).toBe(0); | ||
|
||
jest.setSystemTime(1000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
|
||
expect(Date.now()).toBe(1000); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you update https://github.com/facebook/jest/blob/master/website/versioned_docs/version-26.0/JestObjectAPI.md as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I have (or at least, I intended to) here: https://github.com/facebook/jest/pull/10169/files#diff-82d75bb4a1a86113540ea33c2bd6f24d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, seems I'm blind 😅 Thanks!