diff --git a/src/__tests__/debug.js b/src/__tests__/debug.js index 89df1bb3..89c0d34f 100644 --- a/src/__tests__/debug.js +++ b/src/__tests__/debug.js @@ -39,3 +39,20 @@ test('debug pretty prints the provided parameter', () => { expect.stringContaining('Hello World'), ) }) + +test('debug pretty prints multiple nodes with the given parameter', () => { + const {getAllByText, debug} = render(HelloWorld) + const multipleElements = getAllByText(/.+/) + + // debug also accepts an array of DOM nodes as a parameter. + debug(multipleElements) + + expect(console.log).toHaveBeenCalledTimes(2) + expect(console.log).toHaveBeenCalledWith( + expect.stringContaining('Hello World'), + ) + + expect(console.log).toHaveBeenCalledWith( + expect.stringContaining('Lorem ipsum dolor sit amet'), + ) +}) diff --git a/src/vue-testing-library.js b/src/vue-testing-library.js index acfb1176..028b8406 100644 --- a/src/vue-testing-library.js +++ b/src/vue-testing-library.js @@ -68,7 +68,8 @@ function render( return { container, baseElement, - debug: (el = baseElement) => logDOM(el), + debug: (el = baseElement) => + Array.isArray(el) ? el.forEach(e => logDOM(e)) : logDOM(el), unmount: () => wrapper.destroy(), isUnmounted: () => wrapper.vm._isDestroyed, html: () => wrapper.html(),