Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tests] assertLog before act in useEffectEvent #28763

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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!" />,
Expand All @@ -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(
Expand All @@ -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
Expand Down