From cc0158ceb1534f86d4cf9373c6053954cf045582 Mon Sep 17 00:00:00 2001 From: Josh Story Date: Tue, 19 Apr 2022 16:32:53 -0700 Subject: [PATCH] Fix failing test related to client render fallbacks This test was actually subject to the project identified in the issue fixed in this branch. After fixing the underlying issue the assertion logic needed to change to pick the right warning which now emits after hydration successfully completes on promise resolution. I changed the container type to 'section' to make the error message slightly easier to read/understand (for me) --- .../ReactDOMServerPartialHydration-test.internal.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js index 66bfdf9a39ed4..9f6d7febfd444 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js @@ -295,7 +295,7 @@ describe('ReactDOMServerPartialHydration', () => { } try { const finalHTML = ReactDOMServer.renderToString(); - const container = document.createElement('div'); + const container = document.createElement('section'); container.innerHTML = finalHTML; expect(Scheduler).toHaveYielded([ 'Hello', @@ -360,12 +360,14 @@ describe('ReactDOMServerPartialHydration', () => { ); if (__DEV__) { - expect(mockError.mock.calls[0]).toEqual([ + const secondToLastCall = + mockError.mock.calls[mockError.mock.calls.length - 2]; + expect(secondToLastCall).toEqual([ 'Warning: Expected server HTML to contain a matching <%s> in <%s>.%s', - 'div', - 'div', + 'article', + 'section', '\n' + - ' in div (at **)\n' + + ' in article (at **)\n' + ' in Component (at **)\n' + ' in Suspense (at **)\n' + ' in App (at **)',