File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -19,4 +19,21 @@ test('debug pretty prints the container', () => {
1919 )
2020} )
2121
22+ test ( 'debug pretty prints multiple containers' , ( ) => {
23+ const HelloWorld = ( ) => (
24+ < >
25+ < h1 data-testid = "testId" > Hello World</ h1 >
26+ < h1 data-testid = "testId" > Hello World</ h1 >
27+ </ >
28+ )
29+ const { getAllByTestId, debug} = render ( < HelloWorld /> )
30+ const multipleElements = getAllByTestId ( 'testId' )
31+ debug ( multipleElements )
32+
33+ expect ( console . log ) . toHaveBeenCalledTimes ( 2 )
34+ expect ( console . log ) . toHaveBeenCalledWith (
35+ expect . stringContaining ( 'Hello World' ) ,
36+ )
37+ } )
38+
2239/* eslint no-console:0 */
Original file line number Diff line number Diff line change @@ -60,8 +60,12 @@ function render(
6060 return {
6161 container,
6262 baseElement,
63- // eslint-disable-next-line no-console
64- debug : ( el = baseElement ) => console . log ( prettyDOM ( el ) ) ,
63+ debug : ( el = baseElement ) =>
64+ Array . isArray ( el )
65+ ? // eslint-disable-next-line no-console
66+ el . forEach ( e => console . log ( prettyDOM ( e ) ) )
67+ : // eslint-disable-next-line no-console,
68+ console . log ( prettyDOM ( el ) ) ,
6569 unmount : ( ) => ReactDOM . unmountComponentAtNode ( container ) ,
6670 rerender : rerenderUi => {
6771 render ( wrapUiIfNeeded ( rerenderUi ) , { container, baseElement} )
You can’t perform that action at this time.
0 commit comments