dillon1000/react

Commit

[scheduler] Improve naive fallback version used in non-DOM environments

Added some tests for the non-DOM version of Scheduler that is used
as a fallback, e.g. Jest. The tests use Jest's fake timers API:

- `jest.runAllTimers(ms)` flushes all scheduled work, as expected
- `jest.advanceTimersByTime(ms)` flushes only callbacks that expire
within the given milliseconds.

These capabilities should be sufficient for most product tests. Because
jest's fake timers do not override performance.now or Date.now, we
assume time is constant. This means Scheduler's internal time will not
be aligned with other code that reads from `performance.now`. For finer
control, the user can override `window._sched` like we do in our tests.
We will likely publish a Jest package that has this built in.
Browse files
Changed paths2 files
First-parent comparison
M packages/scheduler/src/Scheduler.js ModifiedA packages/scheduler/src/__tests__/SchedulerNoDOM-test.internal.js Added
Patch

Files changed

Rendering syntax-highlighted changes…