testing-library / angular-testing-library

🐙 Simple and complete Angular testing utilities that encourage good testing practices
https://testing-library.com/angular
MIT License
709 stars 90 forks source link

How to test components with ViewEncapsulation.ShadowDom? #290

Open 2YY opened 2 years ago

2YY commented 2 years ago

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.

timdeschryver commented 2 years ago

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.

ralfting commented 1 year ago

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.

jtrentes commented 6 months ago

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