From 269bd40a953a5339ad47c643f9b9dbce88ab878d Mon Sep 17 00:00:00 2001 From: "Sebastian \"Sebbie\" Silbermann" Date: Wed, 26 Aug 2026 19:24:58 +0200 Subject: [PATCH] [test] Remove the custom `toThrow` override for legacy V8 error messages (#37384) The custom `toThrow` override in `scripts/jest/matchers/toThrow.js` wrapped the built-in matcher to rewrite the pre-Node-17 V8 error message format ("Cannot read property 'x' of undefined") into the modern one ("Cannot read properties of undefined (reading 'x')"), so the test suite could run on Node 12 to 16. On the Node versions this repo runs on (20 per `.nvmrc`, 24 in CI), V8 only ever produces the modern format, so the override is a passthrough. Mostly removing this because the custom matcher deep-imports `expect/build/toThrowMatchers`, which no longer resolves on Jest 30 because each Jest package is now bundled into a single file, so this removal unblocks the Jest 30 upgrade stacked on top. Co-authored-by: Claude Code (kimi-k3[1m]) --- .../__tests__/ReactServerRendering-test.js | 16 +++--- .../ReactHooksWithNoopRenderer-test.js | 2 +- scripts/jest/matchers/toThrow.js | 50 ------------------- scripts/jest/setupTests.js | 1 - .../spec-equivalence-reporter/setupTests.js | 1 - 5 files changed, 9 insertions(+), 61 deletions(-) delete mode 100644 scripts/jest/matchers/toThrow.js diff --git a/packages/react-dom/src/__tests__/ReactServerRendering-test.js b/packages/react-dom/src/__tests__/ReactServerRendering-test.js index c071d3ff47b5..4a78a17117af 100644 --- a/packages/react-dom/src/__tests__/ReactServerRendering-test.js +++ b/packages/react-dom/src/__tests__/ReactServerRendering-test.js @@ -147,7 +147,7 @@ describe('ReactDOMServer', () => { it('should throw with silly args', () => { expect( ReactDOMServer.renderToString.bind(ReactDOMServer, {x: 123}), - ).toThrowError( + ).toThrow( 'Objects are not valid as a React child (found: object with keys {x})', ); }); @@ -155,7 +155,7 @@ describe('ReactDOMServer', () => { it('should throw prop mapping error for an