Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Mar 1, 2024
1 parent 2a9eb01 commit 6acaed9
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2403,7 +2403,7 @@ describe('ReactDOMFizzServer', () => {
]);
}).toErrorDev(
[
'Warning: An error occurred during hydration. The server HTML was replaced with client content in <div>.',
'Warning: An error occurred during hydration. The server HTML was replaced with client content.',
'Warning: Expected server HTML to contain a matching <div> in <div>.\n' +
' in div (at **)\n' +
' in App (at **)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
}).toErrorDev(
[
'Expected server HTML to contain a matching <span> in <span>',
'An error occurred during hydration. The server HTML was replaced with client content in <div>.',
'An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
Expand Down Expand Up @@ -337,7 +337,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
}).toErrorDev(
[
'Did not expect server HTML to contain the text node "Server" in <span>',
'An error occurred during hydration. The server HTML was replaced with client content in <div>.',
'An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
Expand Down Expand Up @@ -385,7 +385,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
}).toErrorDev(
[
'Expected server HTML to contain a matching text node for "Client" in <span>.',
'An error occurred during hydration. The server HTML was replaced with client content in <div>.',
'An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
Expand Down Expand Up @@ -436,7 +436,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
}).toErrorDev(
[
'Did not expect server HTML to contain the text node "Server" in <span>.',
'An error occurred during hydration. The server HTML was replaced with client content in <div>.',
'An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
Expand Down Expand Up @@ -485,7 +485,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
}).toErrorDev(
[
'Expected server HTML to contain a matching text node for "Client" in <span>.',
'An error occurred during hydration. The server HTML was replaced with client content in <div>.',
'An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
Expand Down Expand Up @@ -608,7 +608,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
}).toErrorDev(
[
'Expected server HTML to contain a matching <p> in <div>.',
'An error occurred during hydration. The server HTML was replaced with client content in <div>.',
'An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
Expand Down Expand Up @@ -654,7 +654,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
}).toErrorDev(
[
'Did not expect server HTML to contain a <p> in <div>.',
'An error occurred during hydration. The server HTML was replaced with client content in <div>.',
'An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/__tests__/ReactDOMFloat-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6459,7 +6459,7 @@ body {
}).toErrorDev(
[
'Warning: Text content did not match. Server: "server" Client: "client"',
'Warning: An error occurred during hydration. The server HTML was replaced with client content in <#document>.',
'Warning: An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
Expand Down Expand Up @@ -8275,7 +8275,7 @@ background-color: green;
}).toErrorDev(
[
'Warning: Text content did not match. Server: "server" Client: "client"',
'Warning: An error occurred during hydration. The server HTML was replaced with client content in <#document>.',
'Warning: An error occurred during hydration. The server HTML was replaced with client content.',
],
{withoutStack: 1},
);
Expand Down
79 changes: 43 additions & 36 deletions packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/react-dom/src/__tests__/ReactDOMOption-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe('ReactDOMOption', () => {
}).toErrorDev(
[
'Warning: Text content did not match. Server: "FooBaz" Client: "Foo"',
'Warning: An error occurred during hydration. The server HTML was replaced with client content in <div>',
'Warning: An error occurred during hydration. The server HTML was replaced with client content.',
'Warning: In HTML, <div> cannot be a child of <option>',
],
{withoutStack: 1},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ describe('ReactDOMServerPartialHydration', () => {
expect(secondToLastCall).toEqual([
'Warning: Expected server HTML to contain a matching <%s> in <%s>.%s',
'article',
'section',
'Suspense',
'\n' +
' in article (at **)\n' +
' in Component (at **)\n' +
Expand Down Expand Up @@ -530,7 +530,9 @@ describe('ReactDOMServerPartialHydration', () => {
},
});
});
}).toErrorDev('Did not expect server HTML to contain a <span> in <Suspense>');
}).toErrorDev(
'Did not expect server HTML to contain a <span> in <Suspense>',
);

expect(container.innerHTML).toContain('<span>A</span>');
expect(container.innerHTML).not.toContain('<span>B</span>');
Expand Down Expand Up @@ -3263,8 +3265,8 @@ describe('ReactDOMServerPartialHydration', () => {
}).toErrorDev(
[
'Warning: An error occurred during hydration. ' +
'The server HTML was replaced with client content in <div>.',
'Warning: Expected server HTML to contain a matching <span> in <div>.\n' +
'The server HTML was replaced with client content.',
'Warning: Expected server HTML to contain a matching <span> in the root.\n' +
' in span (at **)\n' +
' in App (at **)',
],
Expand Down Expand Up @@ -3310,7 +3312,7 @@ describe('ReactDOMServerPartialHydration', () => {
[
'Text content did not match. Server: "good" Client: "bad"',
'An error occurred during hydration. The server HTML was replaced with ' +
'client content in <div>.',
'client content.',
],
{withoutStack: 1},
);
Expand Down Expand Up @@ -3354,7 +3356,7 @@ describe('ReactDOMServerPartialHydration', () => {
[
'Text content did not match. Server: "good" Client: "bad"',
'An error occurred during hydration. The server HTML was replaced with ' +
'client content in <div>.',
'client content.',
],
{withoutStack: 1},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ describe('ReactDOM HostSingleton', () => {
in div (at **)
in body (at **)
in html (at **)`,
`Warning: An error occurred during hydration. The server HTML was replaced with client content in <#document>.`,
`Warning: An error occurred during hydration. The server HTML was replaced with client content.`,
],
{withoutStack: 1},
);
Expand Down
10 changes: 5 additions & 5 deletions packages/react-dom/src/__tests__/ReactRenderDocument-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ describe('rendering React components at document', () => {
});
}).toErrorDev(
[
'Warning: An error occurred during hydration. The server HTML was replaced with client content in <div>.',
'Warning: An error occurred during hydration. The server HTML was replaced with client content.',
'Expected server HTML to contain a matching <div> in <div>.',
],
{withoutStack: 1},
Expand Down Expand Up @@ -233,7 +233,7 @@ describe('rendering React components at document', () => {
});
}).toErrorDev(
[
'Warning: An error occurred during hydration. The server HTML was replaced with client content in <div>.',
'Warning: An error occurred during hydration. The server HTML was replaced with client content.',
'Expected server HTML to contain a matching <div> in <div>.',
],
{withoutStack: 1},
Expand Down Expand Up @@ -279,7 +279,7 @@ describe('rendering React components at document', () => {
});
}).toErrorDev(
[
'Warning: An error occurred during hydration. The server HTML was replaced with client content in <#document>.',
'Warning: An error occurred during hydration. The server HTML was replaced with client content.',
'Warning: Text content did not match.',
],
{
Expand Down Expand Up @@ -326,7 +326,7 @@ describe('rendering React components at document', () => {
});
}).toErrorDev(
[
'Warning: An error occurred during hydration. The server HTML was replaced with client content in <#document>.',
'Warning: An error occurred during hydration. The server HTML was replaced with client content.',
'Expected server HTML to contain a matching text node for "Hello world" in <body>',
],
{withoutStack: 1},
Expand All @@ -351,7 +351,7 @@ describe('rendering React components at document', () => {
});
}).toErrorDev(
[
'Warning: An error occurred during hydration. The server HTML was replaced with client content in <#document>.',
'Warning: An error occurred during hydration. The server HTML was replaced with client content.',
'Warning: Text content did not match. Server: "test doc" Client: "Hello World"',
],
{withoutStack: 1},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe('ReactDOMServerHydration', () => {
});
}).toErrorDev(
[
'An error occurred during hydration. The server HTML was replaced with client content in <div>.',
'An error occurred during hydration. The server HTML was replaced with client content.',
'Text content did not match. Server: "x" Client: "y"',
],
{withoutStack: 1},
Expand Down Expand Up @@ -225,7 +225,7 @@ describe('ReactDOMServerHydration', () => {
});
}).toErrorDev(
[
'An error occurred during hydration. The server HTML was replaced with client content in <div>.',
'An error occurred during hydration. The server HTML was replaced with client content.',
'Warning: Text content did not match. Server: "server" Client: "client"',
],
{withoutStack: 1},
Expand Down Expand Up @@ -534,7 +534,7 @@ describe('ReactDOMServerHydration', () => {
expect(domElement.innerHTML).not.toEqual(markup);
}).toErrorDev(
[
'An error occurred during hydration. The server HTML was replaced with client content in <div>.',
'An error occurred during hydration. The server HTML was replaced with client content.',
'Warning: Text content did not match. Server: "server" Client: "client"',
],
{withoutStack: 1},
Expand All @@ -560,7 +560,7 @@ describe('ReactDOMServerHydration', () => {
expect(domElement.innerHTML).not.toEqual(markup);
}).toErrorDev(
[
'An error occurred during hydration. The server HTML was replaced with client content in <div>.',
'An error occurred during hydration. The server HTML was replaced with client content.',
'Warning: Did not expect server HTML to contain a <p> in <div>.',
],
{withoutStack: 1},
Expand Down
2 changes: 1 addition & 1 deletion scripts/jest/shouldIgnoreConsoleError.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = function shouldIgnoreConsoleError(
if (
TODO_ignoreHydrationErrors &&
format.indexOf(
'An error occurred during hydration. The server HTML was replaced with client content in'
'An error occurred during hydration. The server HTML was replaced with client content'
) !== -1
) {
// This also gets logged by onRecoverableError, so we can ignore it.
Expand Down

0 comments on commit 6acaed9

Please sign in to comment.