mirror of
https://github.com/callstack/react-native-testing-library.git
synced 2026-09-18 23:09:04 +08:00
111b1c9277
* 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>
23 lines
552 B
JavaScript
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);
|
|
},
|
|
};
|
|
}
|