diff --git a/packages/react-dom/src/__tests__/ReactDOMServerSelectiveHydration-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMServerSelectiveHydration-test.internal.js index ec4d4c76f5750..bb04b46df1c40 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerSelectiveHydration-test.internal.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerSelectiveHydration-test.internal.js @@ -1057,9 +1057,9 @@ describe('ReactDOMServerSelectiveHydration', () => { if (!ref.current) { return; } - ref.current.addEventListener('click', () => { + ref.current.onclick = () => { Scheduler.unstable_yieldValue('Native Click ' + text); - }); + }; }, [text]); return ( { ); } - const finalHTML = ReactDOMServer.renderToString(); - if (__DEV__) { - expect(console.error).toHaveBeenCalledTimes(2); - expect(console.error.calls.argsFor(0)[0]).toContain( - 'useLayoutEffect does nothing on the server', - ); - expect(console.error.calls.argsFor(1)[0]).toContain( - 'useLayoutEffect does nothing on the server', - ); - } + let finalHTML; + expect(() => { + finalHTML = ReactDOMServer.renderToString(); + }).toErrorDev([ + 'useLayoutEffect does nothing on the server', + 'useLayoutEffect does nothing on the server', + ]); expect(Scheduler).toHaveYielded(['App', 'A', 'B']); @@ -1132,8 +1129,5 @@ describe('ReactDOMServerSelectiveHydration', () => { expect(Scheduler).toFlushAndYield(['A']); document.body.removeChild(container); - if (__DEV__) { - expect(console.error).toHaveBeenCalledTimes(2); - } }); });