[testing-helpers] Allow to inject wrapper element in fixture
See original GitHub issueCurrently there’s no way to customize the creation of wrapper element used as parent to the template.
A use case is testing an element that uses the dependency injection technique described by Polymer dev here and here. It relies on a parent element that listen to an event dispatched in the connectedCallback
An actual example of testing is here. app-header
element depends on a context provided by a parent element. Currently there’s no way to properly test it.
This is something i can work if approved
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Testing Components – Testing Angular
Let us wrap the code in a Jasmine test suite. describe('CounterComponent', () => { let fixture: ComponentFixture<CounterComponent>; ...
Read more >Write your tests - PatternFly Elements
A test fixture renders a piece of HTML and injects into the DOM so that you can test the behavior of your component....
Read more >Testing Your Web Components · Blog
Creating a custom element for a demo todo list in a test driven ... The @open-wc/testing-helpers give a function fixture that allows us...
Read more >web component - Lit Element, unit testing - Nested Elements
For this we have created another component, <carousel-helper> , which has the code to accept an array of markups and render it as...
Read more >open-wc/testing-helpers - npm
You don't need to use lit-html in your project to use the test fixtures, it just renders standard HTML. Test a custom element....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Changing the implementation of the component (with complexity increase and performance penalty) just to allow testing does not sound good
Even considering the above, context provider elements does not deals with children rendering at all
Yes, the solution is to await the rendering for the child element like below:
With the following caveats
Finally, the code required to implement the ability to define the the wrapper/parent is moving one line in one place (the remaining code just pass options argument down the call stack).
Its less than the required code to implement one test case with the proposed solution
Allowing setting the wrapper element does seem like a simple solution as well given the complexities. @daKmoR what do you think?