Skip to content

Commit b5564b5

Browse files
committed
refactor: flush microtasks after event
1 parent 28923f0 commit b5564b5

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/user-event/utils/dispatch-event.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ReactTestInstance } from 'react-test-renderer';
22
import act from '../../act';
33
import { isEventEnabled, isTouchResponder } from '../../fireEvent';
4+
import { flushMicroTasks } from '../../flushMicroTasks';
45
import { getHostParent } from '../../helpers/component-tree';
56

67
type EventHandler = (event: unknown) => void;
@@ -24,6 +25,7 @@ export function dispatchHostEvent(
2425

2526
act(() => {
2627
handler(event);
28+
flushMicroTasks();
2729
});
2830
}
2931

@@ -47,6 +49,7 @@ export function dispatchOwnHostEvent(
4749

4850
act(() => {
4951
handler(event);
52+
flushMicroTasks();
5053
});
5154
}
5255

0 commit comments

Comments
 (0)