From b72da4e256f37402f2387663802fbd730a735ddd Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Mon, 20 Apr 2020 12:49:06 +0200 Subject: [PATCH] test: add similar test that should trigger the warning --- .../ReactServerRenderingHydration-test.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js b/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js index b622598c7d964..419fda91e2696 100644 --- a/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js +++ b/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js @@ -564,4 +564,25 @@ describe('ReactDOMServerHydration', () => { expect(domElement.innerHTML).toEqual(markup); }); + + it('should warns if innerHTML mismatches with dangerouslySetInnerHTML=undefined on the client', () => { + const domElement = document.createElement('div'); + const markup = ReactDOMServer.renderToStaticMarkup( +
server

'}} />, + ); + domElement.innerHTML = markup; + + expect(() => { + ReactDOM.hydrate( +
+

client

+
, + domElement, + ); + + expect(domElement.innerHTML).not.toEqual(markup); + }).toErrorDev( + 'Warning: Text content did not match. Server: "server" Client: "client"', + ); + }); });