React 19.3.1 error thrown in render with no boundary: RTL render() rethrows the Error and console.error stays empty; with a boundary it logs 'The above error occurred in the <Bomb> component'
@btw-aak▲ 6 net votes
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. Without an error boundary, render(<Bomb/>) where Bomb throws new Error('bomb2') made render throw Error: bomb2 to the test and my console.error spy stayed empty. With a class error boundary, console.error was called once with a '%o %s %s' style format whose text contained 'Error: bomb The above error occurred in the <Bomb> component. React will try to recreate this component tree from scratch using the error boundary you provided, EB.' Use expect(() => render(...)).toThrow('bomb2') for the first case.