@@ -82,10 +82,10 @@ describe("<SuspenseWrapper />", () => {
8282 ) ;
8383
8484 // Should show error message and retry button
85- expect ( screen . getByText ( "There was an error!" ) ) . toBeInTheDocument ( ) ;
86- expect (
87- screen . getByRole ( "button" , { name : "Try again" } ) ,
88- ) . toBeInTheDocument ( ) ;
85+ const errorButton = screen . getByRole ( "button" , {
86+ name : "A UI element failed to render. Click to retry." ,
87+ } ) ;
88+ expect ( errorButton ) . toBeInTheDocument ( ) ;
8989 expect ( screen . queryByTestId ( "success-content" ) ) . not . toBeInTheDocument ( ) ;
9090 } ) ;
9191
@@ -106,8 +106,10 @@ describe("<SuspenseWrapper />", () => {
106106 ) ;
107107
108108 // Initially shows error
109- expect ( screen . getByText ( "There was an error!" ) ) . toBeInTheDocument ( ) ;
110- const retryButton = screen . getByRole ( "button" , { name : "Try again" } ) ;
109+ const retryButton = screen . getByRole ( "button" , {
110+ name : "A UI element failed to render. Click to retry." ,
111+ } ) ;
112+ expect ( retryButton ) . toBeInTheDocument ( ) ;
111113
112114 // Fix the error condition and click retry
113115 shouldError = false ;
@@ -118,7 +120,11 @@ describe("<SuspenseWrapper />", () => {
118120 expect ( screen . getByTestId ( "recovered-content" ) ) . toBeInTheDocument ( ) ;
119121 } ) ;
120122 expect ( screen . getByText ( "Recovered" ) ) . toBeInTheDocument ( ) ;
121- expect ( screen . queryByText ( "There was an error!" ) ) . not . toBeInTheDocument ( ) ;
123+ expect (
124+ screen . queryByRole ( "button" , {
125+ name : "A UI element failed to render. Click to retry." ,
126+ } ) ,
127+ ) . not . toBeInTheDocument ( ) ;
122128 } ) ;
123129
124130 test ( "shows custom errorFallback when provided" , ( ) => {
@@ -145,9 +151,10 @@ describe("<SuspenseWrapper />", () => {
145151 expect ( screen . getByTestId ( "custom-retry" ) ) . toBeInTheDocument ( ) ;
146152
147153 // Should NOT show default error UI
148- expect ( screen . queryByText ( "There was an error!" ) ) . not . toBeInTheDocument ( ) ;
149154 expect (
150- screen . queryByRole ( "button" , { name : "Try again" } ) ,
155+ screen . queryByRole ( "button" , {
156+ name : "A UI element failed to render. Click to retry." ,
157+ } ) ,
151158 ) . not . toBeInTheDocument ( ) ;
152159 } ) ;
153160
@@ -376,10 +383,10 @@ describe("withSuspenseWrapper()", () => {
376383 render ( < WrappedComponent /> ) ;
377384
378385 // Should show error UI
379- expect ( screen . getByText ( "There was an error!" ) ) . toBeInTheDocument ( ) ;
380- expect (
381- screen . getByRole ( "button" , { name : "Try again" } ) ,
382- ) . toBeInTheDocument ( ) ;
386+ const errorButton = screen . getByRole ( "button" , {
387+ name : "A UI element failed to render. Click to retry." ,
388+ } ) ;
389+ expect ( errorButton ) . toBeInTheDocument ( ) ;
383390 } ) ;
384391
385392 test ( "wrapped component can recover from error" , async ( ) => {
@@ -397,11 +404,14 @@ describe("withSuspenseWrapper()", () => {
397404 render ( < WrappedComponent /> ) ;
398405
399406 // Initially shows error
400- expect ( screen . getByText ( "There was an error!" ) ) . toBeInTheDocument ( ) ;
407+ const retryButton = screen . getByRole ( "button" , {
408+ name : "A UI element failed to render. Click to retry." ,
409+ } ) ;
410+ expect ( retryButton ) . toBeInTheDocument ( ) ;
401411
402412 // Fix error and retry
403413 shouldError = false ;
404- fireEvent . click ( screen . getByRole ( "button" , { name : "Try again" } ) ) ;
414+ fireEvent . click ( retryButton ) ;
405415
406416 // Should recover
407417 await waitFor ( ( ) => {
0 commit comments