* 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)
| 182 | * @see https://github.com/testing-library/user-event/blob/7a305dee9ab833d6f338d567fc2e862b4838b76a/src/setup/setup.ts#L121 |
| 183 | */ |
| 184 | function 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 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…