shadow-dom-testing-library
Version:
An extension of DOM-testing-library to provide hooks into the shadow dom
1 lines • 91.7 kB
Source Map (JSON)
{"version":3,"sources":["../src/index.ts","../src/shadow-queries.ts","../src/trick-dom-testing-library.ts","../src/deep-query-selectors.ts","../src/log-shadow-dom.ts","../src/pretty-shadow-dom.ts","../src/debug.ts","../src/shadow-screen.ts","../src/shadow-within.ts"],"sourcesContent":["import { configure, getConfig } from \"@testing-library/dom\";\n\nimport * as shadowQueries from \"./shadow-queries\";\nimport { debug } from \"./debug\";\nimport { logShadowDOM } from \"./log-shadow-dom\";\nimport { prettyShadowDOM } from \"./pretty-shadow-dom\";\nimport { shadowScreen } from \"./shadow-screen\";\nimport { shadowWithin } from \"./shadow-within\";\n\nconfigure({\n // https://github.com/testing-library/dom-testing-library/blob/39a64d4b862f706d09f0cd225ce9eda892f1e8d8/src/config.ts#L36-L51\n getElementError(message, container) {\n const prettifiedDOM = prettyShadowDOM(container);\n const error = new Error(\n [\n message,\n `Ignored nodes: comments, ${\n getConfig().defaultIgnore\n }\\n${prettifiedDOM}`,\n ]\n .filter(Boolean)\n .join(\"\\n\\n\"),\n );\n error.name = \"ShadowDOMTestingLibraryElementError\";\n return error;\n },\n});\n\nexport * from \"./types\";\nexport * from \"./shadow-queries\";\n\nexport { createDOMElementFilter } from \"./pretty-shadow-dom\";\n\nexport {\n deepQuerySelector,\n deepQuerySelectorAll,\n getAllElementsAndShadowRoots,\n} from \"./deep-query-selectors\";\n\nexport {\n shadowScreen as screen,\n shadowWithin as within,\n shadowQueries,\n debug,\n logShadowDOM,\n prettyShadowDOM,\n};\n","import {\n buildQueries,\n ByRoleMatcher,\n queryAllByRole,\n queryAllByLabelText,\n Matcher,\n queryAllByPlaceholderText,\n queryAllByText,\n queryAllByDisplayValue,\n queryAllByAltText,\n queryAllByTitle,\n queryAllByTestId,\n AllByRole,\n AllByText,\n AllByBoundAttribute,\n GetByRole,\n QueryByRole,\n FindByRole,\n FindAllByRole,\n QueryByText,\n GetByText,\n FindAllByText,\n FindByText,\n QueryByBoundAttribute,\n GetByBoundAttribute,\n FindAllByBoundAttribute,\n FindByBoundAttribute,\n} from \"@testing-library/dom\";\n\nimport { getAllElementsAndShadowRoots } from \"./deep-query-selectors\";\nimport { patchWrap } from \"./trick-dom-testing-library\";\nimport {\n ScreenShadowMatcherParams,\n ScreenShadowRoleMatcherParams,\n ScreenShadowSelectorMatcherParams,\n ShadowMatcherParams,\n ShadowRoleMatcherParams,\n ShadowSelectorMatcherParams,\n} from \"./types\";\n\nfunction toShadowQueries<T extends Function[]>(queries: T): T {\n return queries.map((query): Function => {\n return (...args: any[]): unknown => {\n let [arg1, arg2, options, ...rest] = args;\n if (options == null) options = {};\n options.suggest = false;\n return query(arg1, arg2, options, ...rest);\n };\n }) as T;\n}\n\n// Role\nfunction queryAllByShadowRole<T extends HTMLElement = HTMLElement>(\n ...args: ShadowRoleMatcherParams\n): ReturnType<AllByRole<T>> {\n let [container, role, options] = args;\n\n if (options == null) {\n options = {};\n }\n\n options.suggest = false;\n\n return [\n ...new Set(\n patchWrap(() =>\n getAllElementsAndShadowRoots(container, options)\n .map((el) => queryAllByRole(el as HTMLElement, role, options))\n .flat(Infinity),\n ),\n ),\n ] as T[];\n}\n\nconst getMultipleRoleError = (_c: Element | null, role: ByRoleMatcher) =>\n `Found multiple elements with the role of: ${role}`;\nconst getMissingRoleError = (_c: Element | null, role: ByRoleMatcher) =>\n `Unable to find an element with the role of: ${role}`;\n\nconst [\n _queryByShadowRole,\n _getAllByShadowRole,\n _getByShadowRole,\n _findAllByShadowRole,\n _findByShadowRole,\n] = toShadowQueries(\n buildQueries<ScreenShadowRoleMatcherParams>(\n queryAllByShadowRole,\n getMultipleRoleError,\n getMissingRoleError,\n ),\n);\n\nconst queryByShadowRole = <T extends HTMLElement>(\n ...args: Parameters<typeof _queryByShadowRole>\n) => _queryByShadowRole(...args) as ReturnType<QueryByRole<T>>;\nconst getAllByShadowRole = <T extends HTMLElement>(\n ...args: Parameters<typeof _getAllByShadowRole>\n) => _getAllByShadowRole(...args) as Array<ReturnType<GetByRole<T>>>;\nconst getByShadowRole = <T extends HTMLElement>(\n ...args: Parameters<typeof _getByShadowRole>\n) => _getByShadowRole(...args) as ReturnType<GetByRole<T>>;\nconst findAllByShadowRole = <T extends HTMLElement>(\n ...args: Parameters<typeof _findAllByShadowRole>\n) => _findAllByShadowRole(...args) as ReturnType<FindAllByRole<T>>;\nconst findByShadowRole = <T extends HTMLElement>(\n ...args: Parameters<typeof _findByShadowRole>\n) => _findByShadowRole(...args) as ReturnType<FindByRole<T>>;\n\n// Label Text\nfunction queryAllByShadowLabelText<T extends HTMLElement = HTMLElement>(\n ...args: ShadowSelectorMatcherParams\n): ReturnType<AllByText<T>> {\n let [container, id, options] = args;\n\n if (options == null) {\n options = {};\n }\n\n options.suggest = false;\n\n return [\n ...new Set(\n patchWrap(() =>\n getAllElementsAndShadowRoots(container, options)\n .map((el) => queryAllByLabelText(el as HTMLElement, id, options))\n .flat(Infinity),\n ),\n ),\n ] as T[];\n}\n\nconst getMultipleLabelTextError = (_c: Element | null, id: Matcher) =>\n `Found multiple elements with the label text of: ${id}`;\nconst getMissingLabelTextError = (_c: Element | null, id: Matcher) =>\n `Unable to find an element with the label text of: ${id}`;\n\nconst [\n _queryByShadowLabelText,\n _getAllByShadowLabelText,\n _getByShadowLabelText,\n _findAllByShadowLabelText,\n _findByShadowLabelText,\n] = toShadowQueries(\n buildQueries<ScreenShadowSelectorMatcherParams>(\n queryAllByShadowLabelText,\n getMultipleLabelTextError,\n getMissingLabelTextError,\n ),\n);\n\nconst queryByShadowLabelText = <T extends HTMLElement>(\n ...args: Parameters<typeof _queryByShadowLabelText>\n) => _queryByShadowLabelText(...args) as ReturnType<QueryByText<T>>;\nconst getAllByShadowLabelText = <T extends HTMLElement>(\n ...args: Parameters<typeof _getAllByShadowLabelText>\n) => _getAllByShadowLabelText(...args) as Array<ReturnType<GetByText<T>>>;\nconst getByShadowLabelText = <T extends HTMLElement>(\n ...args: Parameters<typeof _getByShadowLabelText>\n) => _getByShadowLabelText(...args) as ReturnType<GetByText<T>>;\nconst findAllByShadowLabelText = <T extends HTMLElement>(\n ...args: Parameters<typeof _findAllByShadowLabelText>\n) => _findAllByShadowLabelText(...args) as ReturnType<FindAllByText<T>>;\nconst findByShadowLabelText = <T extends HTMLElement>(\n ...args: Parameters<typeof _findByShadowLabelText>\n) => _findByShadowLabelText(...args) as ReturnType<FindByText<T>>;\n\n// Placeholder Text\nfunction queryAllByShadowPlaceholderText<T extends HTMLElement = HTMLElement>(\n ...args: ShadowMatcherParams\n): ReturnType<AllByText<T>> {\n let [container, id, options] = args;\n\n if (options == null) {\n options = {};\n }\n\n options.suggest = false;\n\n return [\n ...new Set(\n patchWrap(() =>\n getAllElementsAndShadowRoots(container, options)\n .map((el) =>\n queryAllByPlaceholderText(el as HTMLElement, id, options),\n )\n .flat(Infinity),\n ),\n ),\n ] as T[];\n}\n\nconst getMultiplePlaceholderTextError = (_c: Element | null, id: Matcher) =>\n `Found multiple elements with the placeholder text of: ${id}`;\nconst getMissingPlaceholderTextError = (_c: Element | null, id: Matcher) =>\n `Unable to find an element with the placeholder text of: ${id}`;\n\nconst [\n _queryByShadowPlaceholderText,\n _getAllByShadowPlaceholderText,\n _getByShadowPlaceholderText,\n _findAllByShadowPlaceholderText,\n _findByShadowPlaceholderText,\n] = toShadowQueries(\n buildQueries<ScreenShadowSelectorMatcherParams>(\n queryAllByShadowPlaceholderText,\n getMultiplePlaceholderTextError,\n getMissingPlaceholderTextError,\n ),\n);\n\nconst queryByShadowPlaceholderText = <T extends HTMLElement>(\n ...args: Parameters<typeof _queryByShadowPlaceholderText>\n) => _queryByShadowPlaceholderText(...args) as ReturnType<QueryByText<T>>;\nconst getAllByShadowPlaceholderText = <T extends HTMLElement>(\n ...args: Parameters<typeof _getAllByShadowPlaceholderText>\n) => _getAllByShadowPlaceholderText(...args) as Array<ReturnType<GetByText<T>>>;\nconst getByShadowPlaceholderText = <T extends HTMLElement>(\n ...args: Parameters<typeof _getByShadowPlaceholderText>\n) => _getByShadowPlaceholderText(...args) as ReturnType<GetByText<T>>;\nconst findAllByShadowPlaceholderText = <T extends HTMLElement>(\n ...args: Parameters<typeof _findAllByShadowPlaceholderText>\n) => _findAllByShadowPlaceholderText(...args) as ReturnType<FindAllByText<T>>;\nconst findByShadowPlaceholderText = <T extends HTMLElement>(\n ...args: Parameters<typeof _findByShadowPlaceholderText>\n) => _findByShadowPlaceholderText(...args) as ReturnType<FindByText<T>>;\n\n// Text\nfunction queryAllByShadowText<T extends HTMLElement = HTMLElement>(\n ...args: ShadowSelectorMatcherParams\n): ReturnType<AllByText<T>> {\n let [container, id, options] = args;\n\n if (options == null) {\n options = {};\n }\n\n options.suggest = false;\n\n return [\n ...new Set(\n patchWrap(() =>\n getAllElementsAndShadowRoots(container, options)\n .map((el) => queryAllByText(el as HTMLElement, id, options))\n .flat(Infinity),\n ),\n ),\n ] as T[];\n}\n\nconst getMultipleTextError = (_c: Element | null, id: Matcher) =>\n `Found multiple elements with the text of: ${id}`;\nconst getMissingTextError = (_c: Element | null, id: Matcher) =>\n `Unable to find an element with the text of: ${id}`;\n\nconst [\n _queryByShadowText,\n _getAllByShadowText,\n _getByShadowText,\n _findAllByShadowText,\n _findByShadowText,\n] = toShadowQueries(\n buildQueries<ScreenShadowSelectorMatcherParams>(\n queryAllByShadowText,\n getMultipleTextError,\n getMissingTextError,\n ),\n);\n\nconst queryByShadowText = <T extends HTMLElement>(\n ...args: Parameters<typeof _queryByShadowText>\n) => _queryByShadowText(...args) as ReturnType<QueryByText<T>>;\nconst getAllByShadowText = <T extends HTMLElement>(\n ...args: Parameters<typeof _getAllByShadowText>\n) => _getAllByShadowText(...args) as Array<ReturnType<GetByText<T>>>;\nconst getByShadowText = <T extends HTMLElement>(\n ...args: Parameters<typeof _getByShadowText>\n) => _getByShadowText(...args) as ReturnType<GetByText<T>>;\nconst findAllByShadowText = <T extends HTMLElement>(\n ...args: Parameters<typeof _findAllByShadowText>\n) => _findAllByShadowText(...args) as ReturnType<FindAllByText<T>>;\nconst findByShadowText = <T extends HTMLElement>(\n ...args: Parameters<typeof _findByShadowText>\n) => _findByShadowText(...args) as ReturnType<FindByText<T>>;\n\n// Display Value\nfunction queryAllByShadowDisplayValue<T extends HTMLElement = HTMLElement>(\n ...args: ShadowSelectorMatcherParams\n): ReturnType<AllByBoundAttribute<T>> {\n let [container, id, options] = args;\n\n if (options == null) {\n options = {};\n }\n\n options.suggest = false;\n\n return [\n ...new Set(\n patchWrap(() =>\n getAllElementsAndShadowRoots(container, options)\n .map((el) => queryAllByDisplayValue(el as HTMLElement, id, options))\n .flat(Infinity),\n ),\n ),\n ] as T[];\n}\n\nconst getMultipleDisplayValueError = (_c: Element | null, id: Matcher) =>\n `Found multiple elements with the display value of: ${id}`;\nconst getMissingDisplayValueError = (_c: Element | null, id: Matcher) =>\n `Unable to find an element with the display value of: ${id}`;\n\nconst [\n _queryByShadowDisplayValue,\n _getAllByShadowDisplayValue,\n _getByShadowDisplayValue,\n _findAllByShadowDisplayValue,\n _findByShadowDisplayValue,\n] = toShadowQueries(\n buildQueries<ScreenShadowSelectorMatcherParams>(\n queryAllByShadowDisplayValue,\n getMultipleDisplayValueError,\n getMissingDisplayValueError,\n ),\n);\n\nconst queryByShadowDisplayValue = <T extends HTMLElement>(\n ...args: Parameters<typeof _queryByShadowDisplayValue>\n) =>\n _queryByShadowDisplayValue(...args) as ReturnType<QueryByBoundAttribute<T>>;\nconst getAllByShadowDisplayValue = <T extends HTMLElement>(\n ...args: Parameters<typeof _getAllByShadowDisplayValue>\n) =>\n _getAllByShadowDisplayValue(...args) as Array<\n ReturnType<GetByBoundAttribute<T>>\n >;\nconst getByShadowDisplayValue = <T extends HTMLElement>(\n ...args: Parameters<typeof _getByShadowDisplayValue>\n) => _getByShadowDisplayValue(...args) as ReturnType<GetByBoundAttribute<T>>;\nconst findAllByShadowDisplayValue = <T extends HTMLElement>(\n ...args: Parameters<typeof _findAllByShadowDisplayValue>\n) =>\n _findAllByShadowDisplayValue(...args) as ReturnType<\n FindAllByBoundAttribute<T>\n >;\nconst findByShadowDisplayValue = <T extends HTMLElement>(\n ...args: Parameters<typeof _findByShadowDisplayValue>\n) => _findByShadowDisplayValue(...args) as ReturnType<FindByBoundAttribute<T>>;\n\n// Alt Text\nfunction queryAllByShadowAltText<T extends HTMLElement = HTMLElement>(\n ...args: ShadowMatcherParams\n): ReturnType<AllByText<T>> {\n let [container, id, options] = args;\n\n if (options == null) {\n options = {};\n }\n\n options.suggest = false;\n\n return [\n ...new Set(\n patchWrap(() =>\n getAllElementsAndShadowRoots(container, options)\n .map((el) => queryAllByAltText(el as HTMLElement, id, options))\n .flat(Infinity),\n ),\n ),\n ] as T[];\n}\n\nconst getMultipleAltTextError = (_c: Element | null, id: Matcher) =>\n `Found multiple elements with the alt text of: ${id}`;\nconst getMissingAltTextError = (_c: Element | null, id: Matcher) =>\n `Unable to find an element with the alt text of: ${id}`;\n\nconst [\n _queryByShadowAltText,\n _getAllByShadowAltText,\n _getByShadowAltText,\n _findAllByShadowAltText,\n _findByShadowAltText,\n] = toShadowQueries(\n buildQueries<ScreenShadowMatcherParams>(\n queryAllByShadowAltText,\n getMultipleAltTextError,\n getMissingAltTextError,\n ),\n);\n\nconst queryByShadowAltText = <T extends HTMLElement>(\n ...args: Parameters<typeof _queryByShadowAltText>\n) => _queryByShadowAltText(...args) as ReturnType<QueryByText<T>>;\nconst getAllByShadowAltText = <T extends HTMLElement>(\n ...args: Parameters<typeof _getAllByShadowAltText>\n) => _getAllByShadowAltText(...args) as Array<ReturnType<GetByText<T>>>;\nconst getByShadowAltText = <T extends HTMLElement>(\n ...args: Parameters<typeof _getByShadowAltText>\n) => _getByShadowAltText(...args) as ReturnType<GetByText<T>>;\nconst findAllByShadowAltText = <T extends HTMLElement>(\n ...args: Parameters<typeof _findAllByShadowAltText>\n) => _findAllByShadowAltText(...args) as ReturnType<FindAllByText<T>>;\nconst findByShadowAltText = <T extends HTMLElement>(\n ...args: Parameters<typeof _findByShadowAltText>\n) => _findByShadowAltText(...args) as ReturnType<FindByText<T>>;\n\n// Title\nfunction queryAllByShadowTitle<T extends HTMLElement = HTMLElement>(\n ...args: ShadowMatcherParams\n): ReturnType<AllByBoundAttribute<T>> {\n let [container, id, options] = args;\n\n if (options == null) {\n options = {};\n }\n\n options.suggest = false;\n\n return [\n ...new Set(\n patchWrap(() =>\n getAllElementsAndShadowRoots(container, options)\n .map((el) => queryAllByTitle(el as HTMLElement, id, options))\n .flat(Infinity),\n ),\n ),\n ] as T[];\n}\n\nconst getMultipleTitleError = (_c: Element | null, id: Matcher) =>\n `Found multiple elements with the title of: ${id}`;\nconst getMissingTitleError = (_c: Element | null, id: Matcher) =>\n `Unable to find an element with the title of: ${id}`;\n\nconst [\n _queryByShadowTitle,\n _getAllByShadowTitle,\n _getByShadowTitle,\n _findAllByShadowTitle,\n _findByShadowTitle,\n] = toShadowQueries(\n buildQueries<ScreenShadowMatcherParams>(\n queryAllByShadowTitle,\n getMultipleTitleError,\n getMissingTitleError,\n ),\n);\n\nconst queryByShadowTitle = <T extends HTMLElement>(\n ...args: Parameters<typeof _queryByShadowTitle>\n) => _queryByShadowTitle(...args) as ReturnType<QueryByBoundAttribute<T>>;\nconst getAllByShadowTitle = <T extends HTMLElement>(\n ...args: Parameters<typeof _getAllByShadowTitle>\n) => _getAllByShadowTitle(...args) as Array<ReturnType<GetByBoundAttribute<T>>>;\nconst getByShadowTitle = <T extends HTMLElement>(\n ...args: Parameters<typeof _getByShadowTitle>\n) => _getByShadowTitle(...args) as ReturnType<GetByBoundAttribute<T>>;\nconst findAllByShadowTitle = <T extends HTMLElement>(\n ...args: Parameters<typeof _findAllByShadowTitle>\n) => _findAllByShadowTitle(...args) as ReturnType<FindAllByBoundAttribute<T>>;\nconst findByShadowTitle = <T extends HTMLElement>(\n ...args: Parameters<typeof _findByShadowTitle>\n) => _findByShadowTitle(...args) as ReturnType<FindByBoundAttribute<T>>;\n\n// Test Id\nfunction queryAllByShadowTestId<T extends HTMLElement = HTMLElement>(\n ...args: ShadowMatcherParams\n): ReturnType<AllByBoundAttribute<T>> {\n let [container, id, options] = args;\n\n if (options == null) {\n options = {};\n }\n\n options.suggest = false;\n\n return [\n ...new Set(\n patchWrap(() =>\n getAllElementsAndShadowRoots(container, options)\n .map((el) => queryAllByTestId(el as HTMLElement, id, options))\n .flat(Infinity),\n ),\n ),\n ] as T[];\n}\n\nconst getMultipleTestIdError = (_c: Element | null, id: Matcher) =>\n `Found multiple elements with the test id of: ${id}`;\nconst getMissingTestIdError = (_c: Element | null, id: Matcher) =>\n `Unable to find an element with the test id of: ${id}`;\n\nconst [\n _queryByShadowTestId,\n _getAllByShadowTestId,\n _getByShadowTestId,\n _findAllByShadowTestId,\n _findByShadowTestId,\n] = toShadowQueries(\n buildQueries<ScreenShadowMatcherParams>(\n queryAllByShadowTestId,\n getMultipleTestIdError,\n getMissingTestIdError,\n ),\n);\n\nconst queryByShadowTestId = <T extends HTMLElement>(\n ...args: Parameters<typeof _queryByShadowTestId>\n) => _queryByShadowTestId(...args) as ReturnType<QueryByBoundAttribute<T>>;\nconst getAllByShadowTestId = <T extends HTMLElement>(\n ...args: Parameters<typeof _getAllByShadowTestId>\n) =>\n _getAllByShadowTestId(...args) as Array<ReturnType<GetByBoundAttribute<T>>>;\nconst getByShadowTestId = <T extends HTMLElement>(\n ...args: Parameters<typeof _getByShadowTestId>\n) => _getByShadowTestId(...args) as ReturnType<GetByBoundAttribute<T>>;\nconst findAllByShadowTestId = <T extends HTMLElement>(\n ...args: Parameters<typeof _findAllByShadowTestId>\n) => _findAllByShadowTestId(...args) as ReturnType<FindAllByBoundAttribute<T>>;\nconst findByShadowTestId = <T extends HTMLElement>(\n ...args: Parameters<typeof _findByShadowTestId>\n) => _findByShadowTestId(...args) as ReturnType<FindByBoundAttribute<T>>;\n\nexport {\n // Role\n queryAllByShadowRole,\n queryByShadowRole,\n getAllByShadowRole,\n getByShadowRole,\n findAllByShadowRole,\n findByShadowRole,\n\n // Label Text\n queryAllByShadowLabelText,\n queryByShadowLabelText,\n getAllByShadowLabelText,\n getByShadowLabelText,\n findAllByShadowLabelText,\n findByShadowLabelText,\n\n // Placeholder Text\n queryAllByShadowPlaceholderText,\n queryByShadowPlaceholderText,\n getAllByShadowPlaceholderText,\n getByShadowPlaceholderText,\n findAllByShadowPlaceholderText,\n findByShadowPlaceholderText,\n\n // Text\n queryAllByShadowText,\n queryByShadowText,\n getAllByShadowText,\n getByShadowText,\n findAllByShadowText,\n findByShadowText,\n\n // Display Value\n queryAllByShadowDisplayValue,\n queryByShadowDisplayValue,\n getAllByShadowDisplayValue,\n getByShadowDisplayValue,\n findAllByShadowDisplayValue,\n findByShadowDisplayValue,\n\n // Alt Text\n queryAllByShadowAltText,\n queryByShadowAltText,\n getAllByShadowAltText,\n getByShadowAltText,\n findAllByShadowAltText,\n findByShadowAltText,\n\n // Title\n queryAllByShadowTitle,\n queryByShadowTitle,\n getAllByShadowTitle,\n getByShadowTitle,\n findAllByShadowTitle,\n findByShadowTitle,\n\n // Test Id\n queryAllByShadowTestId,\n queryByShadowTestId,\n getAllByShadowTestId,\n getByShadowTestId,\n findAllByShadowTestId,\n findByShadowTestId,\n};\n","declare global {\n interface ShadowRoot {\n matches?: typeof HTMLElement.prototype.matches;\n outerHTML?: typeof HTMLElement.prototype.outerHTML;\n }\n}\n\n// Okay. For some reason shadow root patches cant be part of patchDOM. Haven't figured out why.\n// Only reason I can come up with is the patchWrap() may be conflicting with internals of dom-testing-library?\n// I do know calling `.getByText(el.shadowRoot)` will fail without this patch.\n// outerHTML fails with some issue around \"this\".\n// IDK...but this is weird, no its not the most responsible patch, but it works.\n// Just dont go calling .matches() or .outerHTML() on shadowRoots in your code...\n// This previously existed in other version of SDTL so not a huge deal.\npatchShadowRoot();\n\n// Amazingly fun hack to trick DOM testing libraries internal type checking logic.\n// https://github.com/testing-library/dom-testing-library/blob/73a5694529dbfff289f3d7a01470c45ef5c77715/src/queries/text.ts#L34-L36\n// https://github.com/testing-library/dom-testing-library/blob/73a5694529dbfff289f3d7a01470c45ef5c77715/src/pretty-dom.js#L50-L54\nexport function patchDOM() {\n patchSlotElement();\n}\n\nfunction removeDOMPatch() {\n HTMLSlotElement.prototype.querySelectorAll =\n HTMLElement.prototype.querySelectorAll;\n}\n\nexport function patchWrap<T extends (...args: any) => any>(\n callback: T,\n): ReturnType<T> {\n patchDOM();\n\n try {\n const val = callback();\n\n // We only wrap RTL functions, so I dont think anything returns a promise, but just in-case,\n // lets make sure we clean up.\n if (\n typeof val === \"object\" &&\n \"finally\" in val &&\n typeof val.finally === \"function\"\n ) {\n val.finally(() => removeDOMPatch());\n }\n\n return val;\n } finally {\n removeDOMPatch();\n }\n}\n\nfunction patchShadowRoot() {\n if (typeof ShadowRoot == \"undefined\")\n throw \"Your environment does not support shadow roots.\";\n\n if (ShadowRoot.prototype.matches == null) {\n Object.defineProperties(ShadowRoot.prototype, {\n matches: {\n get() {\n return function (this: ShadowRoot, string: string): boolean {\n const str = string.trim();\n if (str === \"*\") return true;\n\n return Boolean(this.querySelector(string));\n };\n },\n },\n });\n }\n\n if (ShadowRoot.prototype.outerHTML == null) {\n Object.defineProperties(ShadowRoot.prototype, {\n outerHTML: {\n get() {\n return this.innerHTML;\n },\n },\n });\n }\n}\n\nfunction patchSlotElement() {\n HTMLSlotElement.prototype.querySelectorAll = function (str: string) {\n const qsa = HTMLElement.prototype.querySelectorAll;\n let els: Element[] = [];\n\n this.assignedElements({ flatten: true }).forEach((_el) => {\n const el = _el as Element;\n\n // Clone it and make a scratch buffer because we need to check that _el\n // meets the criteria of the querySelector before we push it to \"els\"\n const scratch = document.createElement(\"div\");\n scratch.appendChild(el.cloneNode(false));\n\n if (scratch.querySelector(str)) {\n els.push(el);\n }\n\n els = els.concat(Array.from(el.querySelectorAll(str)));\n });\n\n // So because slots have fallback content, we want to only first query for slotted content.\n // If theres no slotted content, we fallback to using the default content.\n if (els.length == 0) {\n els = Array.from(qsa.call(this, str));\n }\n\n return [...new Set(els)] as unknown as ReturnType<\n typeof HTMLSlotElement.prototype.querySelectorAll\n >;\n };\n}\n","import { patchWrap } from \"./trick-dom-testing-library\";\nimport { Container, ShadowOptions } from \"./types\";\n\nfunction fixOptions(options: ShadowOptions) {\n if (options.shallow != null) {\n console.warn(\n `The \"shallow\" option will be removed in the next major release. Please use \"{depth: 1}\" to maintain the same functionality.`,\n );\n\n if (options.shallow === true) {\n options.depth = 1;\n }\n }\n\n if (!options.depth) {\n options.depth = Infinity;\n }\n\n return options;\n}\n\nexport function deepQuerySelector<T extends HTMLElement>(\n container: Container,\n selector: string,\n options: ShadowOptions = { shallow: false, depth: Infinity },\n): T | null {\n options = fixOptions(options);\n\n const els = deepQuerySelectorAll(container, selector, options);\n\n if (Array.isArray(els) && els.length > 0) {\n return els[0] as T | null;\n }\n\n return null;\n}\n\n/**\n * `deepQuerySelector` behaves like a normal querySelector except it will recurse into the container ShadowRoot\n * and shadowRoot of children. It will not return shadow roots.\n *\n * @example\n * // <my-element>\n * // #shadowRoot <slot name=\"blah\"></slot>\n * // <div></div>\n * // </my-element>\n * deepQuerySelectorAll(myElement, \"*\") // => [slot, div]\n * deepQuerySelectorAll(myElement, \"slot[name='blah']\") // => [slot]\n */\nexport function deepQuerySelectorAll<T extends HTMLElement>(\n container: Container,\n selector: string,\n options: ShadowOptions = { shallow: false, depth: Infinity },\n): T[] {\n options = fixOptions(options);\n\n return patchWrap(() => {\n const elements = getAllElementsAndShadowRoots(container, options);\n\n const queriedElements = elements\n .map((el) => Array.from(el.querySelectorAll<T>(selector)))\n .flat(Infinity) as T[];\n return [...new Set(queriedElements)];\n });\n}\n\n// This could probably get really slow and memory intensive in large DOMs,\n// maybe an infinite generator in the future?\nexport function getAllElementsAndShadowRoots(\n container: Container,\n options: ShadowOptions = { shallow: false, depth: Infinity },\n) {\n options = fixOptions(options);\n const selector = \"*\";\n\n return recurse(container, selector, options);\n}\n\nfunction recurse(\n container: Container,\n selector: string,\n options: ShadowOptions = { shallow: false, depth: Infinity },\n elementsToProcess: (Element | ShadowRoot | Document)[] = [],\n elements: (Element | ShadowRoot | Document)[] = [],\n currentDepth = 1,\n) {\n // if \"document\" is passed in, it will also pick up \"<html>\" causing the query to run twice.\n if (container instanceof Document) {\n container = document.documentElement;\n }\n\n // I haven't figured this one out, but for some reason when using the buildQueries\n // from DOM-testing-library, not reassigning here causes an infinite loop.\n // I've even tried calling \"elementsToProcess.includes / .find\" with no luck.\n elementsToProcess = [container];\n elements.push(container); // Make sure we're checking the container element!\n\n // Accounts for if the container houses a textNode\n if (\n container instanceof HTMLElement &&\n container.shadowRoot != null &&\n container.shadowRoot.mode !== \"closed\"\n ) {\n elements.push(container.shadowRoot);\n elementsToProcess.push(container.shadowRoot);\n }\n\n elementsToProcess.forEach((containerElement) => {\n containerElement\n .querySelectorAll(selector)\n .forEach((el: Element | HTMLElement) => {\n if (el.shadowRoot == null || el.shadowRoot.mode === \"closed\") {\n elements.push(el);\n return;\n }\n\n // This is here because queryByRole() requires the parent element which in some cases is the shadow root.\n elements.push(el.shadowRoot);\n\n if (options.depth && options.depth <= currentDepth) {\n el.shadowRoot.querySelectorAll(selector).forEach((el) => {\n elements.push(el);\n });\n return;\n }\n\n currentDepth++;\n\n el.shadowRoot.querySelectorAll(selector).forEach((el) => {\n elements.push(el);\n elementsToProcess.push(el);\n });\n recurse(\n el.shadowRoot,\n selector,\n options,\n elementsToProcess,\n elements,\n currentDepth,\n );\n });\n });\n\n // We can sometimes hit duplicate nodes this way, lets stop that.\n return [...new Set(elements)];\n}\n","import { logDOM } from \"@testing-library/dom\";\nimport {\n createDOMElementFilter,\n filterCommentsAndDefaultIgnoreTagsTags,\n} from \"./pretty-shadow-dom\";\nimport type { NewPlugin } from \"pretty-format\";\nimport { patchWrap } from \"./trick-dom-testing-library\";\n\nexport function logShadowDOM(\n ...args: Parameters<typeof logDOM>\n): ReturnType<typeof logDOM> {\n let [dom, maxLength, options] = args;\n\n const plugin: NewPlugin = createDOMElementFilter(\n options?.filterNode || filterCommentsAndDefaultIgnoreTagsTags,\n );\n\n if (options == null) options = {};\n if (options.plugins == null) options.plugins = [];\n options.plugins.push(plugin);\n\n patchWrap(() => logDOM(dom, maxLength, options));\n}\n","import { prettyDOM, getConfig } from \"@testing-library/dom\";\nimport type { Config, NewPlugin, Printer, Refs } from \"pretty-format\";\nimport { patchWrap } from \"./trick-dom-testing-library\";\n\n// This regexp combo took way too long to figure out...\nconst findWhiteSpace = /([^\\S(\\r\\n|\\r|\\n)]*[\\f\\n\\r\\t\\v]+)/.source;\n\nfunction removeDuplicateNewLines(str: string) {\n let final = str.replace(\n new RegExp(`${findWhiteSpace}.*${findWhiteSpace}{2,}`, \"g\"),\n \"\",\n );\n return final;\n}\n\nexport function prettyShadowDOM(\n ...args: Parameters<typeof prettyDOM>\n): ReturnType<typeof prettyDOM> {\n let [dom, maxLength, options] = args;\n\n const plugin: NewPlugin = createDOMElementFilter(\n options?.filterNode || filterCommentsAndDefaultIgnoreTagsTags,\n );\n\n if (options == null) options = {};\n if (options.plugins == null) options.plugins = [];\n\n options.plugins.push(plugin);\n\n return patchWrap(() =>\n prettyDOM(dom, maxLength, {\n ...options,\n plugins: [plugin],\n }),\n );\n}\n\nfunction escapeHTML(str: string): string {\n return str.replace(/</g, \"<\").replace(/>/g, \">\");\n}\n\nexport function filterCommentsAndDefaultIgnoreTagsTags(value: Node) {\n return (\n value.nodeType !== COMMENT_NODE &&\n (value.nodeType !== ELEMENT_NODE ||\n // @ts-expect-error\n !value.matches(getConfig().defaultIgnore))\n );\n}\n\n// Return empty string if keys is empty.\nconst printProps = (\n keys: Array<string>,\n props: Record<string, unknown>,\n config: Config,\n indentation: string,\n depth: number,\n refs: Refs,\n printer: Printer,\n): string => {\n const indentationNext = indentation + config.indent;\n const colors = config.colors;\n\n return keys\n .map((key) => {\n const value = props[key];\n let printed = printer(value, config, indentationNext, depth, refs);\n\n if (typeof value !== \"string\") {\n if (printed.indexOf(\"\\n\") !== -1) {\n printed =\n config.spacingOuter +\n indentationNext +\n printed +\n config.spacingOuter +\n indentation;\n }\n printed = \"{\" + printed + \"}\";\n }\n\n return (\n config.spacingInner +\n indentation +\n colors.prop.open +\n key +\n colors.prop.close +\n \"=\" +\n colors.value.open +\n printed +\n colors.value.close\n );\n })\n .join(\"\");\n};\n\n// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType#node_type_constants\nconst NodeTypeTextNode = 3;\n\n// Return empty string if children is empty.\nconst printChildren = (\n children: Array<unknown>,\n config: Config,\n indentation: string,\n depth: number,\n refs: Refs,\n printer: Printer,\n): string =>\n removeDuplicateNewLines(\n children\n .map((child) => {\n const printedChild =\n typeof child === \"string\"\n ? printText(child, config)\n : printer(child, config, indentation, depth, refs);\n\n if (\n printedChild === \"\" &&\n typeof child === \"object\" &&\n child != null &&\n (child as Node).nodeType !== NodeTypeTextNode\n ) {\n // A plugin serialized this Node to '' meaning we should ignore it.\n return \"\";\n }\n return config.spacingOuter + indentation + printedChild;\n })\n .join(\"\"),\n );\n\nconst printText = (text: string, config: Config): string => {\n const contentColor = config.colors.content;\n return contentColor.open + escapeHTML(text) + contentColor.close;\n};\n\nconst printComment = (comment: string, config: Config): string => {\n const commentColor = config.colors.comment;\n return (\n commentColor.open +\n \"<!--\" +\n escapeHTML(comment) +\n \"-->\" +\n commentColor.close\n );\n};\n\n// Separate the functions to format props, children, and element,\n// so a plugin could override a particular function, if needed.\n// Too bad, so sad: the traditional (but unnecessary) space\n// in a self-closing tagColor requires a second test of printedProps.\nconst printElement = (\n type: string,\n printedProps: string,\n printedChildren: string,\n config: Config,\n indentation: string,\n): string => {\n const tagColor = config.colors.tag;\n\n return (\n tagColor.open +\n \"<\" +\n type +\n (printedProps &&\n tagColor.close +\n printedProps +\n config.spacingOuter +\n indentation +\n tagColor.open) +\n (printedChildren\n ? \">\" +\n tagColor.close +\n printedChildren +\n config.spacingOuter +\n indentation +\n tagColor.open +\n \"</\" +\n type\n : (printedProps && !config.min ? \"\" : \" \") + \"/\") +\n \">\" +\n tagColor.close\n );\n};\n\nconst printElementAsLeaf = (type: string, config: Config): string => {\n const tagColor = config.colors.tag;\n return (\n tagColor.open +\n \"<\" +\n type +\n tagColor.close +\n \" …\" +\n tagColor.open +\n \" />\" +\n tagColor.close\n );\n};\n\nconst ELEMENT_NODE = 1;\nconst TEXT_NODE = 3;\nconst COMMENT_NODE = 8;\nconst FRAGMENT_NODE = 11;\n\nconst ELEMENT_REGEXP = /^((HTML|SVG)\\w*)?Element$/;\n\nconst testNode = (val: any) => {\n const constructorName = val?.constructor?.name || \"\";\n const { nodeType, tagName } = val;\n const isCustomElement =\n (typeof tagName === \"string\" && tagName.includes(\"-\")) ||\n (typeof val.hasAttribute === \"function\" && val.hasAttribute(\"is\")) ||\n val instanceof HTMLElement;\n\n return (\n (nodeType === ELEMENT_NODE &&\n (ELEMENT_REGEXP.test(constructorName) || isCustomElement)) ||\n (nodeType === TEXT_NODE && constructorName === \"Text\") ||\n (nodeType === COMMENT_NODE && constructorName === \"Comment\") ||\n // Don't check constructorName === \"DocumentFragment\" because it excludes ShadowRoot.\n nodeType === FRAGMENT_NODE\n );\n};\n\nexport const test: NewPlugin[\"test\"] = (val: any) =>\n val?.constructor?.name && testNode(val);\n\ntype HandledType = Element | Text | Comment | DocumentFragment;\n\nfunction nodeIsText(node: HandledType): node is Text {\n return node.nodeType === TEXT_NODE;\n}\n\nfunction nodeIsComment(node: HandledType): node is Comment {\n return node.nodeType === COMMENT_NODE;\n}\n\nfunction nodeIsFragment(\n node: HandledType,\n): node is DocumentFragment | ShadowRoot {\n return node.nodeType === FRAGMENT_NODE;\n}\n\nexport function createDOMElementFilter(\n filterNode: (node: Node) => boolean,\n): NewPlugin {\n function getChildren(\n node: Element | DocumentFragment | ShadowRoot,\n ): (Node | Element | ShadowRoot)[] {\n const children: (Node | Element | ShadowRoot)[] =\n Array.prototype.slice.call(node.childNodes || node.children);\n\n if (\n \"shadowRoot\" in node &&\n node.shadowRoot != null &&\n node.shadowRoot.mode !== \"closed\"\n ) {\n children.unshift(node.shadowRoot);\n }\n\n return children.filter(filterNode);\n }\n\n return {\n test: (val: any) => val?.constructor && testNode(val),\n serialize: (\n node: HandledType,\n config: Config,\n indentation: string,\n depth: number,\n refs: Refs,\n printer: Printer,\n ) => {\n if (nodeIsText(node)) {\n return printText(node.data, config);\n }\n\n if (nodeIsComment(node)) {\n return printComment(node.data, config);\n }\n\n let type = \"DocumentFragment\";\n\n if (\"tagName\" in node && node.tagName) {\n type = node.tagName.toLowerCase();\n } else if (node instanceof ShadowRoot) {\n type = \"ShadowRoot\";\n }\n\n if (++depth > config.maxDepth) {\n return printElementAsLeaf(type, config);\n }\n\n return printElement(\n type,\n printProps(\n nodeIsFragment(node)\n ? []\n : Array.from(node.attributes)\n .map((attr) => attr.name)\n .sort(),\n nodeIsFragment(node)\n ? {}\n : Array.from(node.attributes).reduce<Record<string, string>>(\n (props, attribute) => {\n props[attribute.name] = attribute.value;\n return props;\n },\n {},\n ),\n config,\n indentation + config.indent,\n depth,\n refs,\n printer,\n ),\n printChildren(\n getChildren(node) as unknown[],\n config,\n indentation + config.indent,\n depth,\n refs,\n printer,\n ),\n config,\n indentation,\n );\n },\n };\n}\n","import { screen } from \"@testing-library/dom\";\nimport { logShadowDOM } from \"./log-shadow-dom\";\n\nexport function debug(...args: Parameters<typeof screen.debug>) {\n let [element, maxLength, options] = args;\n\n Array.isArray(element)\n ? element.forEach((el) => logShadowDOM(el, maxLength, options))\n : logShadowDOM(element, maxLength, options);\n}\n","import { debug } from \"./debug\";\nimport { screen } from \"@testing-library/dom\";\n\nimport * as shadowQueries from \"./shadow-queries\";\nimport {\n AsyncScreenShadowMatcherParams,\n AsyncScreenShadowRoleMatcherParams,\n AsyncScreenShadowSelectorMatcherParams,\n ScreenShadowMatcherParams,\n ScreenShadowRoleMatcherParams,\n ScreenShadowSelectorMatcherParams,\n} from \"./types\";\n\n// Shadows the following: https://testing-library.com/docs/queries/about/#priority\nconst shadowScreen = {\n ...screen,\n debug,\n // Role\n queryAllByShadowRole: <T extends HTMLElement>(\n ...args: ScreenShadowRoleMatcherParams\n ) =>\n shadowQueries.queryAllByShadowRole<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n queryByShadowRole: <T extends HTMLElement>(\n ...args: ScreenShadowRoleMatcherParams\n ) =>\n shadowQueries.queryByShadowRole<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getAllByShadowRole: <T extends HTMLElement>(\n ...args: ScreenShadowRoleMatcherParams\n ) =>\n shadowQueries.getAllByShadowRole<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getByShadowRole: <T extends HTMLElement>(\n ...args: ScreenShadowRoleMatcherParams\n ) =>\n shadowQueries.getByShadowRole<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n findAllByShadowRole: <T extends HTMLElement>(\n ...args: AsyncScreenShadowRoleMatcherParams\n ) =>\n shadowQueries.findAllByShadowRole<T>(\n document.documentElement,\n args[0],\n args[1],\n args[2],\n ),\n findByShadowRole: <T extends HTMLElement>(\n ...args: AsyncScreenShadowRoleMatcherParams\n ) =>\n shadowQueries.findByShadowRole<T>(\n document.documentElement,\n args[0],\n args[1],\n args[2],\n ),\n\n // Label Text\n queryAllByShadowLabelText: <T extends HTMLElement>(\n ...args: ScreenShadowSelectorMatcherParams\n ) =>\n shadowQueries.queryAllByShadowLabelText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n queryByShadowLabelText: <T extends HTMLElement>(\n ...args: ScreenShadowSelectorMatcherParams\n ) =>\n shadowQueries.queryByShadowLabelText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getAllByShadowLabelText: <T extends HTMLElement>(\n ...args: ScreenShadowSelectorMatcherParams\n ) =>\n shadowQueries.getAllByShadowLabelText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getByShadowLabelText: <T extends HTMLElement>(\n ...args: ScreenShadowSelectorMatcherParams\n ) =>\n shadowQueries.getByShadowLabelText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n findAllByShadowLabelText: <T extends HTMLElement>(\n ...args: AsyncScreenShadowSelectorMatcherParams\n ) =>\n shadowQueries.findAllByShadowLabelText<T>(\n document.documentElement,\n args[0],\n args[1],\n args[2],\n ),\n findByShadowLabelText: <T extends HTMLElement>(\n ...args: AsyncScreenShadowSelectorMatcherParams\n ) =>\n shadowQueries.findByShadowLabelText<T>(\n document.documentElement,\n args[0],\n args[1],\n args[2],\n ),\n\n // Placeholder Text\n queryAllByShadowPlaceholderText: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.queryAllByShadowPlaceholderText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n queryByShadowPlaceholderText: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.queryByShadowPlaceholderText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getAllByShadowPlaceholderText: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.getAllByShadowPlaceholderText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getByShadowPlaceholderText: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.getByShadowPlaceholderText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n findAllByShadowPlaceholderText: <T extends HTMLElement>(\n ...args: AsyncScreenShadowMatcherParams\n ) =>\n shadowQueries.findAllByShadowPlaceholderText<T>(\n document.documentElement,\n args[0],\n args[1],\n args[2],\n ),\n findByShadowPlaceholderText: <T extends HTMLElement>(\n ...args: AsyncScreenShadowMatcherParams\n ) =>\n shadowQueries.findByShadowPlaceholderText<T>(\n document.documentElement,\n args[0],\n args[1],\n args[2],\n ),\n\n // Text\n queryAllByShadowText: <T extends HTMLElement>(\n ...args: ScreenShadowSelectorMatcherParams\n ) =>\n shadowQueries.queryAllByShadowText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n queryByShadowText: <T extends HTMLElement>(\n ...args: ScreenShadowSelectorMatcherParams\n ) =>\n shadowQueries.queryByShadowText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getAllByShadowText: <T extends HTMLElement>(\n ...args: ScreenShadowSelectorMatcherParams\n ) =>\n shadowQueries.getAllByShadowText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getByShadowText: <T extends HTMLElement>(\n ...args: ScreenShadowSelectorMatcherParams\n ) =>\n shadowQueries.getByShadowText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n findAllByShadowText: <T extends HTMLElement>(\n ...args: AsyncScreenShadowSelectorMatcherParams\n ) =>\n shadowQueries.findAllByShadowText<T>(\n document.documentElement,\n args[0],\n args[1],\n args[2],\n ),\n findByShadowText: <T extends HTMLElement>(\n ...args: AsyncScreenShadowSelectorMatcherParams\n ) =>\n shadowQueries.findByShadowText<T>(\n document.documentElement,\n args[0],\n args[1],\n args[2],\n ),\n\n // Display Value\n queryAllByShadowDisplayValue: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.queryAllByShadowDisplayValue<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n queryByShadowDisplayValue: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.queryByShadowDisplayValue<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getAllByShadowDisplayValue: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.getAllByShadowDisplayValue<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getByShadowDisplayValue: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.getByShadowDisplayValue<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n findAllByShadowDisplayValue: <T extends HTMLElement>(\n ...args: AsyncScreenShadowMatcherParams\n ) =>\n shadowQueries.findAllByShadowDisplayValue<T>(\n document.documentElement,\n args[0],\n args[1],\n args[2],\n ),\n findByShadowDisplayValue: <T extends HTMLElement>(\n ...args: AsyncScreenShadowMatcherParams\n ) =>\n shadowQueries.findByShadowDisplayValue<T>(\n document.documentElement,\n args[0],\n args[1],\n args[2],\n ),\n\n // Alt Text\n queryAllByShadowAltText: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.queryAllByShadowAltText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n queryByShadowAltText: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.queryByShadowAltText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getAllByShadowAltText: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.getAllByShadowAltText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getByShadowAltText: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.getByShadowAltText<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n findAllByShadowAltText: <T extends HTMLElement>(\n ...args: AsyncScreenShadowMatcherParams\n ) =>\n shadowQueries.findAllByShadowAltText<T>(\n document.documentElement,\n args[0],\n args[1],\n args[2],\n ),\n findByShadowAltText: <T extends HTMLElement>(\n ...args: AsyncScreenShadowMatcherParams\n ) =>\n shadowQueries.findByShadowAltText<T>(\n document.documentElement,\n args[0],\n args[1],\n args[2],\n ),\n\n // Title\n queryAllByShadowTitle: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.queryAllByShadowTitle<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n queryByShadowTitle: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.queryByShadowTitle<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getAllByShadowTitle: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.getAllByShadowTitle<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getByShadowTitle: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.getByShadowTitle<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n findAllByShadowTitle: <T extends HTMLElement>(\n ...args: AsyncScreenShadowMatcherParams\n ) =>\n shadowQueries.findAllByShadowTitle<T>(\n document.documentElement,\n args[0],\n args[1],\n args[2],\n ),\n findByShadowTitle: <T extends HTMLElement>(\n ...args: AsyncScreenShadowMatcherParams\n ) =>\n shadowQueries.findByShadowTitle<T>(\n document.documentElement,\n args[0],\n args[1],\n args[2],\n ),\n\n // Test Id\n queryAllByShadowTestId: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.queryAllByShadowTestId<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n queryByShadowTestId: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.queryByShadowTestId<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getAllByShadowTestId: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.getAllByShadowTestId<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n getByShadowTestId: <T extends HTMLElement>(\n ...args: ScreenShadowMatcherParams\n ) =>\n shadowQueries.getByShadowTestId<T>(\n document.documentElement,\n args[0],\n args[1],\n ),\n findAllByShadowTestId: <T extends HTMLElement>(\n ...args: AsyncScreenShadowMatcherParams\n ) =>\n shadowQueries.findAllByShadowTestId<T>(\n document.documentElement,\n