| 678 | |
| 679 | const Intermediate = ({children}) => children; |
| 680 | const Parent = ({children}) => ( |
| 681 | <Intermediate> |
| 682 | <Child /> |
| 683 | </Intermediate> |
| 684 | ); |
| 685 | const Child = ({children}) => { |
| 686 | console.error('error'); |
| 687 | console.warn('warn'); |
| 688 | return null; |
| 689 | }; |
| 690 | |
| 691 | act(() => |
| 692 | root.render( |
| 693 | <React.StrictMode> |
| 694 | <Parent /> |
| 695 | </React.StrictMode>, |
| 696 | ), |
| 697 | ); |
| 698 | |
| 699 | expect( |
| 700 | global.consoleWarnMock.mock.calls[0].map(normalizeCodeLocInfo), |
| 701 | ).toEqual([ |
| 702 | 'warn', |
| 703 | supportsOwnerStacks |
| 704 | ? '\n in Child (at **)\n in Parent (at **)' |
| 705 | : '\n in Child (at **)\n in Intermediate (at **)\n in Parent (at **)', |
| 706 | ]); |
| 707 | |
| 708 | expect( |
| 709 | global.consoleWarnMock.mock.calls[1].map(normalizeCodeLocInfo), |
| 710 | ).toEqual([ |
| 711 | '\x1b[2;38;2;124;124;124m%s %o\x1b[0m', |
| 712 | 'warn', |
| 713 | supportsOwnerStacks |
| 714 | ? '\n in Child (at **)\n in Parent (at **)' |
| 715 | : 'in Child (at **)\n in Intermediate (at **)\n in Parent (at **)', |
| 716 | ]); |
| 717 | |
| 718 | expect( |
| 719 | global.consoleErrorMock.mock.calls[0].map(normalizeCodeLocInfo), |
| 720 | ).toEqual([ |
| 721 | 'error', |
| 722 | supportsOwnerStacks |
| 723 | ? '\n in Child (at **)\n in Parent (at **)' |
| 724 | : '\n in Child (at **)\n in Intermediate (at **)\n in Parent (at **)', |
| 725 | ]); |
| 726 | expect( |
| 727 | global.consoleErrorMock.mock.calls[1].map(normalizeCodeLocInfo), |
| 728 | ).toEqual([ |
| 729 | '\x1b[2;38;2;124;124;124m%s %o\x1b[0m', |
| 730 | 'error', |
| 731 | supportsOwnerStacks |
| 732 | ? '\n in Child (at **)\n in Parent (at **)' |
| 733 | : 'in Child (at **)\n in Intermediate (at **)\n in Parent (at **)', |
| 734 | ]); |
| 735 | }); |
| 736 | }); |