Skip to content

Commit

Permalink
feat: export shadowQueries (#44)
Browse files Browse the repository at this point in the history
* feat: export shadowQueries

* chore: update readme

* chore: formatting
  • Loading branch information
KonnorRogers committed Jan 6, 2023
1 parent 0ac150f commit 06850fb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Expand Up @@ -251,3 +251,32 @@ import { prettyShadowDOM } from "shadow-dom-testing-library";

prettyShadowDOM(element, maxLength, options); // => string | false
```

## ShadowQueries

Perhaps you don't want the extended screen. That's fine. To
import just the shadowQueries you can do so like this:

```js
import { shadowQueries } from "shadow-dom-testing-library";

test("findByShadowRole", async () => {
render(<Button />);
const btn = await shadowQueries.findByShadowRole("button");
expect(btn).toBeInTheDocument();
});
```

You could also use this method to extend your own screen.

```js
import { shadowQueries } from "shadow-dom-testing-library";
import { screen as DOMScreen } from "@testing-library/dom";

const screen = {
...DOMScreen,
...shadowQueries,
};

screen.getByShadowRole("button");
```
1 change: 1 addition & 0 deletions src/index.ts
Expand Up @@ -30,6 +30,7 @@ export {
export {
shadowScreen as screen,
shadowWithin as within,
shadowQueries,
debug,
logShadowDOM,
prettyShadowDOM,
Expand Down

0 comments on commit 06850fb

Please sign in to comment.