angular-testing-library icon indicating copy to clipboard operation
angular-testing-library copied to clipboard

How to test components with ViewEncapsulation.ShadowDom?

Open 2YY opened this issue 3 years ago • 4 comments

Hi, I'm testing component that used as WebComponent (Angular Element).

And I want to enable shadow DOM encapsulation.

@Component({
  // ...
  encapsulation: ViewEncapsulation.ShadowDom // <- This!
})

But if shadow DOM encapsulation is enabled, Angular Testing Library seems failed find elements in shadow DOM.

Is there anything I can solve this problem?

Thanks.

2YY avatar Mar 30 '22 09:03 2YY

Hi, thanks for raising this issue. Unfortunately, we don't support shadow DOM for now. We're tracking this in DOM Testing Library, if it lands there, it should also be possible to use it with Angular Testing Library.

timdeschryver avatar Mar 30 '22 10:03 timdeschryver

Hey @2YY, I had the same problem and I solved using this library (shadow-dom-testing-library), it works just fine for me. I hope soon we are getting support from Angular Testing Library to get elements in a Shadow DOM.

ralfting avatar Feb 15 '23 15:02 ralfting

Is there any news on this topic? The tracked issue in DOM testing library has not been updated since 2022.

jtrentes avatar Mar 07 '24 14:03 jtrentes