MCPcopy Index your code
hub / github.com/callstack/react-native-testing-library / wrapAndBindImpl

Function wrapAndBindImpl

src/user-event/setup/setup.ts:184–202  ·  view source on GitHub ↗

* Wraps user interaction with `wrapAsync` (temporarily disable `act` environment while * calling & resolving the async callback, then flush the microtask queue) * * This implementation is sourced from `testing-library/user-event` * @see https://github.com/testing-library/user-event/blob/7a305dee

(instance: UserEventInstance, impl: Impl)

Source from the content-addressed store, hash-verified

182 * @see https://github.com/testing-library/user-event/blob/7a305dee9ab833d6f338d567fc2e862b4838b76a/src/setup/setup.ts#L121
183 */
184function wrapAndBindImpl<
185 Args extends never[],
186 Impl extends (this: UserEventInstance, ...args: Args) => Promise<unknown>,
187>(instance: UserEventInstance, impl: Impl) {
188 function method(...args: Args) {
189 return wrapAsync(() =>
190 // eslint-disable-next-line promise/prefer-await-to-then
191 impl.apply(instance, args).then(async (result) => {
192 await wait(instance.config);
193 return result;
194 }),
195 );
196 }
197
198 // Copy implementation name to the returned function
199 Object.defineProperty(method, 'name', { get: () => impl.name });
200
201 return method as Impl;
202}

Callers 1

createInstanceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…