@samitouri / QOS-React / commits / 2243b40aba

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

Fixes tests blocking https://github.com/facebook/react/pull/28737

Ricky committed Apr 10, 2024 at 10:34 UTC 2243b40abad449fe90a9af10f592d0c5c52591d5
1 file changed +1 -5
packages/react-reconciler/src/__tests__/useEffectEvent-test.js
+1 -5
@@ -742,7 +742,7 @@ describe('useEffectEvent', () => {
742 await act(() =>
743 ReactNoop.render(<ChatRoom roomId="general" theme="light" />),
744 );
745 - await act(() => jest.runAllTimers());
745 +
746 assertLog(['Welcome to the general room!', 'Connected! theme: light']);
747 expect(ReactNoop).toMatchRenderedOutput(
748 <span prop="Welcome to the general room!" />,
@@ -752,20 +752,17 @@ describe('useEffectEvent', () => {
752 await act(() =>
753 ReactNoop.render(<ChatRoom roomId="music" theme="light" />),
754 );
755 - await act(() => jest.runAllTimers());
755 assertLog([
756 'Welcome to the music room!',
757 // should trigger a reconnect
758 'Connected! theme: light',
759 ]);
761 -
760 expect(ReactNoop).toMatchRenderedOutput(
761 <span prop="Welcome to the music room!" />,
762 );
763
764 // change theme only
765 await act(() => ReactNoop.render(<ChatRoom roomId="music" theme="dark" />));
768 - await act(() => jest.runAllTimers());
766 // should not trigger a reconnect
767 assertLog(['Welcome to the music room!']);
768 expect(ReactNoop).toMatchRenderedOutput(
@@ -776,7 +773,6 @@ describe('useEffectEvent', () => {
773 await act(() =>
774 ReactNoop.render(<ChatRoom roomId="travel" theme="dark" />),
775 );
779 - await act(() => jest.runAllTimers());
776 assertLog([
777 'Welcome to the travel room!',
778 // should trigger a reconnect