Skip to content

Commit 2243b40

Browse files
authored
[tests] assertLog before act in useEffectEvent (#28763)
Fixes tests blocking #28737
1 parent dfc64c6 commit 2243b40

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

packages/react-reconciler/src/__tests__/useEffectEvent-test.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ describe('useEffectEvent', () => {
742742
await act(() =>
743743
ReactNoop.render(<ChatRoom roomId="general" theme="light" />),
744744
);
745-
await act(() => jest.runAllTimers());
745+
746746
assertLog(['Welcome to the general room!', 'Connected! theme: light']);
747747
expect(ReactNoop).toMatchRenderedOutput(
748748
<span prop="Welcome to the general room!" />,
@@ -752,20 +752,17 @@ describe('useEffectEvent', () => {
752752
await act(() =>
753753
ReactNoop.render(<ChatRoom roomId="music" theme="light" />),
754754
);
755-
await act(() => jest.runAllTimers());
756755
assertLog([
757756
'Welcome to the music room!',
758757
// should trigger a reconnect
759758
'Connected! theme: light',
760759
]);
761-
762760
expect(ReactNoop).toMatchRenderedOutput(
763761
<span prop="Welcome to the music room!" />,
764762
);
765763

766764
// change theme only
767765
await act(() => ReactNoop.render(<ChatRoom roomId="music" theme="dark" />));
768-
await act(() => jest.runAllTimers());
769766
// should not trigger a reconnect
770767
assertLog(['Welcome to the music room!']);
771768
expect(ReactNoop).toMatchRenderedOutput(
@@ -776,7 +773,6 @@ describe('useEffectEvent', () => {
776773
await act(() =>
777774
ReactNoop.render(<ChatRoom roomId="travel" theme="dark" />),
778775
);
779-
await act(() => jest.runAllTimers());
780776
assertLog([
781777
'Welcome to the travel room!',
782778
// should trigger a reconnect

0 commit comments

Comments
 (0)