Skip to content
S

shadow-dom-testing-library

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

by paramagicdevFree

#328in UI Libraries
0In stores

Description

shadow-dom-testing-library extends DOM Testing Library so you can query elements inside shadow DOM. DOM Testing Library does not check shado…

Highlights

  • Shadow-prefixed queries for shadow DOM
  • Screen object and within helpers
  • deepQuerySelector and deepQuerySelectorAll
  • Shallow option to search one shadow root deep
  • Requires jsdom 16.2+ and Jest 26.2+ for Jest users

Ratings & Reviews

No ratings yet

Be the first to rate shadow-dom-testing-library.

People also visit

Q

query-selector-shadow-dom

use querySelector syntax to search for nodes inside of (nested) shadow roots

UI Libraries
Launch
W

@webcomponents/shadydom

Web Components Polyfills

UI Libraries
Launch
L

@lwc/synthetic-shadow

Shadow DOM polyfill by LWC

UI Libraries
Launch
V

vue-shadow-dom

Shadow dom support for Vue

UI Libraries
Launch
W

@webcomponents/shadycss

ShadowDOM style encapsulation shim

UI Libraries
Launch
T

Testing Library

Simple and complete testing utilities that encourage good testing practices

Developer Tools
Launch

shadow-dom-testing-library FAQ

What problem does it solve?

DOM Testing Library does not check shadow roots, so elements nested inside them, such as a button, are hard to query. This library adds shadow queries.

How do I query shadow elements?

Each query has a version with a Shadow prefix before the query type. You can use these through the screen object, or through a within container.

What is the shallow option?

It limits a query to one shadow root deep. The README says a recurseDepth option may come in the future.

Which versions does it need?

For Jest, the README says you need jsdom 16.2 or later and Jest 26.2 or later.

Are there risks with deep queries?

Yes. The README warns that shadow and deep queries recurse through every shadow root, so they can find unintended elements, and that they can be expensive on large DOMs.

What are the best shadow-dom-testing-library alternatives?

Popular alternatives to shadow-dom-testing-library include query-selector-shadow-dom, @webcomponents/shadydom and @lwc/synthetic-shadow. See all shadow-dom-testing-library alternatives

Developer Stuff

Badges