diff --git a/docs/dom-testing-library/api-configuration.mdx b/docs/dom-testing-library/api-configuration.mdx index 98eee3e70..ddf636923 100644 --- a/docs/dom-testing-library/api-configuration.mdx +++ b/docs/dom-testing-library/api-configuration.mdx @@ -116,3 +116,39 @@ message and container object as arguments. The global timeout value in milliseconds used by `waitFor` utilities. Defaults to 1000ms. + +### `queryElement` & `queryAllElements` + +If your application requires a specific way to query elements on the page, you +can define a custom strategy used by the testing library. + +For that register your strategy once: + +```js +configure({ + queryElement: (element, query) => element.querySelector(query), + queryAllElements: (element, query) => element.querySelectorAll(query), +}) +``` + +Defaults to `element.querySelector` and `element.querySelectorAll`. + +The interface of the functions will take two arguments, `element` and `query`, +which the wrapper can use. The expected return value is a single element (for +`queryElement`) or a list of elements (for `queryAllElements`). + +This can be used to extend queries to reach into the shadow dom or iframes. An +example using the +[query-selector-shadow-dom](https://github.com/Georgegriff/query-selector-shadow-dom) +library looks like the following: + +```js +import { + querySelectorAllDeep, + querySelectorDeep, +} from 'query-selector-shadow-dom' +configure({ + queryElement: querySelectorDeep, + queryAllElements: querySelectorAllDeep, +}) +```