UNPKG

shadow-dom-testing-library

Version:

An extension of DOM-testing-library to provide hooks into the shadow dom

24 lines (19 loc) 701 B
import { logDOM } from "@testing-library/dom"; import { createDOMElementFilter, filterCommentsAndDefaultIgnoreTagsTags, } from "./pretty-shadow-dom"; import type { NewPlugin } from "pretty-format"; import { patchWrap } from "./trick-dom-testing-library"; export function logShadowDOM( ...args: Parameters<typeof logDOM> ): ReturnType<typeof logDOM> { let [dom, maxLength, options] = args; const plugin: NewPlugin = createDOMElementFilter( options?.filterNode || filterCommentsAndDefaultIgnoreTagsTags, ); if (options == null) options = {}; if (options.plugins == null) options.plugins = []; options.plugins.push(plugin); patchWrap(() => logDOM(dom, maxLength, options)); }