chore: add new debug parameters on testing library react (#38872)

This commit is contained in:
Daniel Afonso 2019-10-08 00:12:38 +01:00 committed by Armando Aguirre
parent 9ddcefd7ec
commit cf165bfcf1
2 changed files with 12 additions and 1 deletions

View File

@ -5,6 +5,7 @@
// Sebastian Silbermann <https://github.com/eps1lon>
// Weyert de Boer <https://github.com/weyert>
// Ifiok Jr. <https://github.com/ifiokjr>
// Daniel Afonso <https://github.com/danieljcafonso>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
@ -16,7 +17,7 @@ export * from '@testing-library/dom';
export type RenderResult<Q extends Queries = typeof queries> = {
container: HTMLElement;
baseElement: HTMLElement;
debug: (baseElement?: HTMLElement | DocumentFragment) => void;
debug: (baseElement?: HTMLElement | DocumentFragment | Array<HTMLElement | DocumentFragment>) => void;
rerender: (ui: React.ReactElement) => void;
unmount: () => boolean;
asFragment: () => DocumentFragment;

View File

@ -46,3 +46,13 @@ async function testFireEvent() {
const { container } = render(<button />);
fireEvent.click(container);
}
async function testDebug() {
const { debug, getAllByTestId } = render(
<>
<h2 data-testid="testid">Hello World</h2>
<h2 data-testid="testid">Hello World</h2>
</>,
);
debug(getAllByTestId('testid'));
}