MCPcopy
hub / github.com/callstack/react-native-testing-library / wrapAsync

Function wrapAsync

src/helpers/wrap-async.ts:12–24  ·  view source on GitHub ↗
(callback: () => Promise<Result>)

Source from the content-addressed store, hash-verified

10 * @returns Result of the callback
11 */
12export async function wrapAsync<Result>(callback: () => Promise<Result>): Promise<Result> {
13 const previousActEnvironment = getIsReactActEnvironment();
14 setReactActEnvironment(false);
15
16 try {
17 const result = await callback();
18 // Flush the microtask queue before restoring the `act` environment
19 await flushMicroTasks();
20 return result;
21 } finally {
22 setReactActEnvironment(previousActEnvironment);
23 }
24}

Callers 2

waitForFunction · 0.90
methodFunction · 0.90

Calls 2

getIsReactActEnvironmentFunction · 0.90
flushMicroTasksFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…