Skip to content

Commit

Permalink
test: add similar test that should trigger the warning
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Apr 20, 2020
1 parent 47c0e9e commit b72da4e
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<div dangerouslySetInnerHTML={{__html: '<p>server</p>'}} />,
);
domElement.innerHTML = markup;

expect(() => {
ReactDOM.hydrate(
<div dangerouslySetInnerHTML={undefined}>
<p>client</p>
</div>,
domElement,
);

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

0 comments on commit b72da4e

Please # to comment.