({level, children})
| 982 | |
| 983 | it('Errors in boundaries should be sent to the client and reported on client render - Error before flushing', async () => { |
| 984 | function Indirection({level, children}) { |
| 985 | if (level > 0) { |
| 986 | return <Indirection level={level - 1}>{children}</Indirection>; |
| 987 | } |
| 988 | return children; |
| 989 | } |
| 990 | |
| 991 | const theError = new Error('uh oh'); |
| 992 | |
| 993 | function Erroring({isClient}) { |
| 994 | if (isClient) { |
| 995 | return 'Hello World'; |
| 996 | } |
| 997 | throw theError; |
| 998 | } |
| 999 | |
| 1000 | function App({isClient}) { |
| 1001 | return ( |
| 1002 | <div> |
| 1003 | <Suspense fallback={<span>loading...</span>}> |
| 1004 | <Indirection level={2}> |
| 1005 | <Erroring isClient={isClient} /> |
| 1006 | </Indirection> |
| 1007 | </Suspense> |
| 1008 | </div> |
| 1009 | ); |
| 1010 | } |
| 1011 | |
| 1012 | const loggedErrors = []; |
| 1013 | function onError(x) { |
| 1014 | loggedErrors.push(x); |
| 1015 | return 'hash(' + x.message + ')'; |
| 1016 | } |
| 1017 | const expectedDigest = onError(theError); |
| 1018 | loggedErrors.length = 0; |
| 1019 | |
| 1020 | await act(() => { |
| 1021 | const {pipe} = renderToPipeableStream( |
| 1022 | <App />, |
| 1023 | |
| 1024 | { |
| 1025 | onError, |
| 1026 | }, |
| 1027 | ); |
| 1028 | pipe(writable); |
| 1029 | }); |
| 1030 | expect(loggedErrors).toEqual([theError]); |
| 1031 | |
| 1032 | const errors = []; |
| 1033 | // Attempt to hydrate the content. |
| 1034 | ReactDOMClient.hydrateRoot(container, <App isClient={true} />, { |
| 1035 | onRecoverableError(error, errorInfo) { |
| 1036 | errors.push({error, errorInfo}); |
| 1037 | }, |
| 1038 | }); |
| 1039 | await waitForAll([]); |
| 1040 | |
| 1041 | expect(getVisibleChildren(container)).toEqual(<div>Hello World</div>); |
nothing calls this directly
no test coverage detected