Skip to content

Commit

Permalink
[Fizz] Add failing test for failed hydration when using uSES in Stric…
Browse files Browse the repository at this point in the history
…tMode
  • Loading branch information
eps1lon committed Feb 6, 2023
1 parent 855b77c commit c2900ae
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2342,6 +2342,50 @@ describe('ReactDOMFizzServer', () => {
},
);

it('can hydrate uSES in StrictMode with different client and server snapshot', async () => {
function subscribe() {
return () => {};
}
function getClientSnapshot() {
return 'Yay!';
}
function getServerSnapshot() {
return 'Nay!';
}

function App() {
const value = useSyncExternalStore(
subscribe,
getClientSnapshot,
getServerSnapshot,
);
Scheduler.unstable_yieldValue(value);

return value;
}

const element = (
<React.StrictMode>
<App />
</React.StrictMode>
);

await act(async () => {
const {pipe} = renderToPipeableStream(element);
pipe(writable);
});
expect(Scheduler).toHaveYielded(['Nay!']);

ReactDOMClient.hydrateRoot(container, element);
expect(() => {
expect(Scheduler).toFlushAndYield([
'Nay!',
// Missing flushAndYield
// 'Yay!'
]);
}).toErrorDev([]);
});

it(
'errors during hydration force a client render at the nearest Suspense ' +
'boundary, and during the client render it recovers',
Expand Down

0 comments on commit c2900ae

Please sign in to comment.