@@ -52,6 +52,7 @@ describe('serverRenderReactComponent', () => {
5252 assertIsString ( renderResult ) ;
5353 const { html, hasErrors } : RenderResult = JSON . parse ( renderResult ) as RenderResult ;
5454
55+ assertIsString ( html ) ;
5556 const result = html && html . indexOf ( '>HELLO</div>' ) > 0 ;
5657 expect ( result ) . toBeTruthy ( ) ;
5758 expect ( hasErrors ) . toBeFalsy ( ) ;
@@ -76,6 +77,7 @@ describe('serverRenderReactComponent', () => {
7677 assertIsString ( renderResult ) ;
7778 const { html, hasErrors } : RenderResult = JSON . parse ( renderResult ) as RenderResult ;
7879
80+ assertIsString ( html ) ;
7981 const result = html && html . indexOf ( 'XYZ' ) > 0 && html . indexOf ( 'Exception in rendering!' ) > 0 ;
8082 expect ( result ) . toBeTruthy ( ) ;
8183 expect ( hasErrors ) . toBeTruthy ( ) ;
@@ -183,8 +185,8 @@ describe('serverRenderReactComponent', () => {
183185 await expect ( renderResult . then ( ( r ) => r . hasErrors ) ) . resolves . toBeFalsy ( ) ;
184186 } ) ;
185187
186- // When an async render function returns an object, serverRenderReactComponent will return the object as it after stringifying it .
187- // It does not validate properties like renderedHtml or hasErrors; it simply returns the stringified object.
188+ // When an async render function returns an object, serverRenderReactComponent will return the object as it is .
189+ // It does not validate properties like renderedHtml or hasErrors; it simply returns the object.
188190 // This behavior can cause issues with the ruby_on_rails gem.
189191 // To avoid such issues, ensure that the returned object includes a `componentHtml` property and use the `react_component_hash` helper.
190192 // This is demonstrated in the "can render async render function used with react_component_hash helper" test.
@@ -206,7 +208,7 @@ describe('serverRenderReactComponent', () => {
206208 const renderResult = serverRenderReactComponent ( renderParams ) ;
207209 assertIsPromise ( renderResult ) ;
208210 const html = await renderResult . then ( ( r ) => r . html ) ;
209- expect ( html ) . toEqual ( JSON . stringify ( resultObject ) ) ;
211+ expect ( html ) . toMatchObject ( resultObject ) ;
210212 } ) ;
211213
212214 // Because the object returned by the async render function is returned as it is,
@@ -229,7 +231,7 @@ describe('serverRenderReactComponent', () => {
229231 const renderResult = serverRenderReactComponent ( renderParams ) ;
230232 assertIsPromise ( renderResult ) ;
231233 const result = await renderResult ;
232- expect ( result . html ) . toEqual ( JSON . stringify ( reactComponentHashResult ) ) ;
234+ expect ( result . html ) . toMatchObject ( reactComponentHashResult ) ;
233235 } ) ;
234236
235237 it ( 'serverRenderReactComponent renders async render function that returns react component' , async ( ) => {
@@ -270,6 +272,7 @@ describe('serverRenderReactComponent', () => {
270272 assertIsString ( renderResult ) ;
271273 const { html, hasErrors } : RenderResult = JSON . parse ( renderResult ) as RenderResult ;
272274
275+ assertIsString ( html ) ;
273276 const result = html && html . indexOf ( 'renderer' ) > 0 && html . indexOf ( 'Exception in rendering!' ) > 0 ;
274277 expect ( result ) . toBeTruthy ( ) ;
275278 expect ( hasErrors ) . toBeTruthy ( ) ;
0 commit comments