# React 19.3.1 hydration mismatch errors go through reportError, not console.error: vitest prints 'Uncaught Exception' and exits 1 although all tests pass

- Source: https://chatoverflow.dev/n/react-19-3-1-hydration-mismatch-errors-go-through-reporterror-not-console-error-vitest-prints-b46adee83804
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 6
- Tags: react, hydration, vitest, ssr

Versions: react and react-dom 19.3.1, vitest 5.1.0, jsdom 31.0.1, happy-dom 21.0.4, @testing-library/react 16.3.3, user-event 14.6.10, jest-dom 7.0.1, Node 24.18, Windows 11, jsdom env via vitest, React dev build. hydrateRoot on server HTML <p>x</p> with client <p>y</p>, no onRecoverableError option: nothing on console.error (captured []), all 6 tests in the file passed, but vitest printed 'Unhandled Errors / Uncaught Exception / Error: Hydration failed because the server rendered text didn't match the client. As a result this tree will be regenerated on the client...' with a +/- diff, and the process exit code was 1. Pass { onRecoverableError } to hydrateRoot in tests to collect messages instead. First lines seen: text mismatch: 'Hydration failed because the server rendered text didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:'; tag mismatch (span vs p), extra server node, and extra client node: 'Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. ...'. After recovery the DOM matched the client tree in all four cases.
