Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Oct 26, 2018
1 parent 4f56345 commit 412c055
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- `[babel-preset-jest]` [**BREAKING**] Export a function instead of an object for Babel 7 compatibility ([#7203](https://github.com/facebook/jest/pull/7203))
- `[expect]` Check constructor equality in .toStrictEqual() ([#7005](https://github.com/facebook/jest/pull/7005))
- `[jest-util]` Add `jest.getTimerCount()` to get the count of scheduled fake timers ([#7285](https://github.com/facebook/jest/pull/7285))
- `[jest-util]`[**BREAKING**] Replace Jest's fake timers implementation with Lolex ([#5171](https://github.com/facebook/jest/pull/5171))

### Fixes

Expand Down
8 changes: 8 additions & 0 deletions docs/JestObjectAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,14 @@ This means, if any timers have been scheduled (but have not yet executed), they

Returns the number of fake timers still left to run.

### `.jest.setSystemTime()`

Set the current system time used by fake timers. Simulates a user changing the system clock while your program is running. It affects the current time but it does not in itself cause e.g. timers to fire; they will fire exactly as they would have done without the call to `jest.setSystemTime()`.

### `.jest.getRealSystemTime()`

When mocking time, `Date.now()` will also be mocked. If you for some reason need access to the real current time, you can invoke this function.

## Misc

### `jest.setTimeout(timeout)`
Expand Down
17 changes: 5 additions & 12 deletions packages/jest-util/src/__tests__/fake_timers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ describe('FakeTimers', () => {
});

timers.runOnlyPendingTimers();
expect(runOrder).toEqual([
const firsRunOrder = [
'mock4',
'mock5',
'mock2',
Expand All @@ -502,20 +502,13 @@ describe('FakeTimers', () => {
'mock3',
'mock1',
'mock2',
]);
];

expect(runOrder).toEqual(firsRunOrder);

timers.runOnlyPendingTimers();
expect(runOrder).toEqual([
'mock4',
'mock5',
'mock2',
'mock2',
'mock1',
'mock2',
'mock2',
'mock3',
'mock1',
'mock2',
...firsRunOrder,
'mock2',
'mock1',
'mock2',
Expand Down

0 comments on commit 412c055

Please sign in to comment.