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

Failing test for ignored suppressHydrationWarning using hydrateRoot #25635

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMServerIntegratio

let React;
let ReactDOM;
let ReactDOMClient;
let ReactDOMServer;
let ReactTestUtils;
let act;

function initModules() {
// Reset warning cache.
jest.resetModuleRegistry();

React = require('react');
ReactDOM = require('react-dom');
ReactDOMClient = require('react-dom/client');
ReactDOMServer = require('react-dom/server');
ReactTestUtils = require('react-dom/test-utils');
act = require('jest-react').act;

// Make them available to the helpers.
return {
Expand Down Expand Up @@ -357,6 +361,30 @@ describe('ReactDOMServerIntegration', () => {
<div>{''}</div>,
));

it('can explicitly ignore reconnecting new children', async () => {
const container = document.createElement('div');
container.innerHTML = ReactDOMServer.renderToString(
<div suppressHydrationWarning={true}>{null}</div>,
);

const recoverableErrors = [];
act(() => {
ReactDOMClient.hydrateRoot(
container,
<div suppressHydrationWarning={true}>
<p>Hello, Dave!</p>
</div>,
{
onRecoverableError: error => {
recoverableErrors.push(error);
},
},
);
});

expect(recoverableErrors).toEqual([]);
});

it('can explicitly ignore reconnecting more children', () =>
expectMarkupMatch(
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,5 +384,7 @@ module.exports = function(initModules) {
clientRenderOnServerString,
renderIntoDom,
streamRender,
ReactDOMServer,
ReactDOM,
};
};