Files
callstack__react-native-tes…/src/flushMicroTasks.js
T
Michał Pierzchała 111b1c9277 fix: modern jest timers (#397)
* fix: modern jest timers

* treat modern timers as default, but be explicit in tests

* we're node-only

* rename to Thenable

* add clarifications; unify test names

* Update src/__tests__/auto-cleanup-skip.test.js

Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>

Co-authored-by: Maciej Jastrzebski <mdjastrzebski@gmail.com>
2020-07-10 16:18:31 +02:00

23 lines
552 B
JavaScript

// @flow
import { printDeprecationWarning } from './helpers/errors';
type Thenable<T> = { then: (() => T) => mixed };
/**
* Wait for microtasks queue to flush
*/
export default function flushMicrotasksQueue<T>(): Thenable<T> {
printDeprecationWarning('flushMicrotasksQueue');
return flushMicroTasks();
}
export function flushMicroTasks<T>(): Thenable<T> {
return {
// using "thenable" instead of a Promise, because otherwise it breaks when
// using "modern" fake timers
then(resolve) {
setImmediate(resolve);
},
};
}