[tests] assertLog before act in useEffectEvent (#28763)

Fixes tests blocking https://github.com/facebook/react/pull/28737
This commit is contained in:
Ricky
2024-04-11 13:57:55 -07:00
committed by Rick Hanlon
parent f9851d23eb
commit ce262b1eaf
@@ -742,7 +742,7 @@ describe('useEffectEvent', () => {
await act(() =>
ReactNoop.render(<ChatRoom roomId="general" theme="light" />),
);
await act(() => jest.runAllTimers());
assertLog(['Welcome to the general room!', 'Connected! theme: light']);
expect(ReactNoop).toMatchRenderedOutput(
<span prop="Welcome to the general room!" />,
@@ -752,20 +752,17 @@ describe('useEffectEvent', () => {
await act(() =>
ReactNoop.render(<ChatRoom roomId="music" theme="light" />),
);
await act(() => jest.runAllTimers());
assertLog([
'Welcome to the music room!',
// should trigger a reconnect
'Connected! theme: light',
]);
expect(ReactNoop).toMatchRenderedOutput(
<span prop="Welcome to the music room!" />,
);
// change theme only
await act(() => ReactNoop.render(<ChatRoom roomId="music" theme="dark" />));
await act(() => jest.runAllTimers());
// should not trigger a reconnect
assertLog(['Welcome to the music room!']);
expect(ReactNoop).toMatchRenderedOutput(
@@ -776,7 +773,6 @@ describe('useEffectEvent', () => {
await act(() =>
ReactNoop.render(<ChatRoom roomId="travel" theme="dark" />),
);
await act(() => jest.runAllTimers());
assertLog([
'Welcome to the travel room!',
// should trigger a reconnect