99'use strict' ;
1010
1111let React ;
12- let ReactDOM ;
12+ let ReactDOMClient ;
13+ let act ;
1314
1415describe ( 'ReactError' , ( ) => {
1516 let globalErrorMock ;
@@ -27,7 +28,8 @@ describe('ReactError', () => {
2728 }
2829 jest . resetModules ( ) ;
2930 React = require ( 'react' ) ;
30- ReactDOM = require ( 'react-dom' ) ;
31+ ReactDOMClient = require ( 'react-dom/client' ) ;
32+ act = require ( 'internal-test-utils' ) . act ;
3133 } ) ;
3234
3335 afterEach ( ( ) => {
@@ -39,20 +41,35 @@ describe('ReactError', () => {
3941 // @gate build === "production"
4042 // @gate !source
4143 it ( 'should error with minified error code' , ( ) => {
42- expect ( ( ) => ReactDOM . render ( 'Hi' , null ) ) . toThrowError (
44+ expect ( ( ) => {
45+ ReactDOMClient . createRoot ( null ) ;
46+ } ) . toThrowError (
4347 'Minified React error #200; visit ' +
4448 'https://react.dev/errors/200' +
4549 ' for the full message or use the non-minified dev environment' +
4650 ' for full errors and additional helpful warnings.' ,
4751 ) ;
4852 } ) ;
4953
50- it ( 'should serialize arguments' , ( ) => {
54+ // @gate build === "production"
55+ // @gate !source
56+ it ( 'should serialize arguments' , async ( ) => {
5157 function Oops ( ) {
52- return ;
58+ return { } ;
5359 }
5460 Oops . displayName = '#wtf' ;
61+
5562 const container = document . createElement ( 'div' ) ;
56- expect ( ( ) => ReactDOM . render ( < Oops /> , container ) ) . not . toThrowError ( ) ;
63+ const root = ReactDOMClient . createRoot ( container ) ;
64+ await expect ( async ( ) => {
65+ await act ( async ( ) => {
66+ root . render ( < Oops /> ) ;
67+ } ) ;
68+ } ) . rejects . toThrow (
69+ 'Minified React error #152; visit ' +
70+ 'https://reactjs.org/docs/error-decoder.html?invariant=152&args[]=%23wtf' +
71+ ' for the full message or use the non-minified dev environment' +
72+ ' for full errors and additional helpful warnings.' ,
73+ ) ;
5774 } ) ;
5875} ) ;
0 commit comments