Comments (8)
Sure: We have the sdx-teaser component. It has sdx-tag as a child in its shadow. Everything which has to do with sdx-tag is tested in tag.e2e. This component should be a "black box" for sdx-teaser. There is no need for a teaser test to go into the tag's shadow. I can not see a use case for that. And if I really want to, I could do it with >>>.
If you see each web component as a independent system the .find()
function should not look into each shadow to find an element.
from stencil.
I agree, this should be at least configurable, similar how the newSpecPage
allows to define the components that are suppose to be loaded. WebdriverIO has similar options when it comes to Stencil component tests.
For now, all I can do is to ingest this into our backlog and find a resolution on this with the team. Thanks for your input.
from stencil.
I think this is working as expected based on the Stencil doc.
By default Stencil will look into all shadow roots to find the element.
FWIW, I also thought this was a bug when the feature was introduced, as I would expect the opposite (explicit >>>
per shadow root to look into).
from stencil.
Thanks for clarifying @jcfranco
The Stencil docs state that:
By default Stencil will look into all shadow roots to find the element.
@danyball do you have an idea how we can make the docs more clear? It does not seem like that there is a way to query only the shadow root of a specific component.
from stencil.
So I can not run the test in my reproducer repo without adding classes or something like that? What if I dont just have this simple component in component setup? Could be difficult to get the correct element if there are multiple levels with multiple ".label" classes in there.
Maybe a solution could be to change the order of "look into all shadow roots": first of all check the level0 shadow, and if nothing found start searching in all other shadow roots.
A little hint: the test in my reproducer repo breaks since 4.14.0, so this version is a breaking change release. Maybe mark it in some way.
The docs could show an example, like:
It is not possible to just search for an element in a specific shadow root. If you have this structure...
<foo-component>
#shadow-root (open)
<bar-component>
#shadow-root (open)
<div class="label" />
</bar-component>
<div class="label">
Hello, World! I'm {this.getText()}
</div>
</foo-component>;
... you need to use a helper class to select the lower .label
element. foo-component >>> .label
will return the one in bar-component.
from stencil.
Maybe a solution could be to change the order of "look into all shadow roots": first of all check the level0 shadow, and if nothing found start searching in all other shadow roots.
I can see why this would be an interesting solution given how the current selector works. However all query commands usually work in a way that they find whatever element comes first in the DOM. Now, in a "Shadow-dom-less" world we could just do foo-component > .label
but this won't work.
A little hint: the test in my reproducer repo breaks since 4.14.0, so this version is a breaking change release. Maybe mark it in some way.
Well, that behavior was broken (even if it was working for you).
One workaround could be:
await page.setContent('<my-component first="foo"></my-component2>');
const element = await page.find('my-component')
expect(element.shadowRoot.querySelector('.label').textContent)
.toEqualText("Hello, World! I'm foo");
from stencil.
Thanks for the workaround! But would be cool to have an E2EElement to do something like expect(await label.isVisible()).toBe(true)
.
A last idea regarding "looking in all shadow doms" logic:
A webcomponent is a delimited element. All tests should relate exclusively to this element and not include elements of other shadow doms. Because these elements in turn are tested in the test of this component. If I am explicit interested in one of these nested shadows, I could use the cool new deep piercing selector.
from stencil.
@danyball can you please elaborate on this last idea?
from stencil.
Related Issues (20)
- bug: cannot get value of inherited custom CSS prop in a shadow DOM element via `E2EElement` APIs HOT 2
- cannot identified the prompts.js as a function?? HOT 17
- bug: generated filename is too long HOT 3
- bug: missing root element's scope id as classname in nested child HOT 4
- bug: Failing to load a nested component hides all parents HOT 1
- bug: child input element is receiving un-wanted props HOT 11
- bug: watchIgnoredRegex is not respected during `stencil build --watch`
- bug: `autofocus` prop/attr is defined on other HTML attribute types instead of `HTMLAttributes` HOT 2
- bug: HOT 6
- bug: missing root element's scope id as classname in user provided children HOT 2
- Attribute ping is missing on AnchorHTMLAttributes HOT 3
- bug: Cannot read properties of undefined (reading 'isProxied') HOT 2
- bug: Stencil v4.18.1 breaks support for Jest v26 HOT 10
- bug: intermediate parents' scope ids are not reflected to the children elements HOT 2
- bug: Removing polyfills except for es5 builds breaks existing installs HOT 10
- bug: __mocks__ copied to output target HOT 3
- bug: Cannot access uninitialized variable, only in Safari, works with dev build HOT 3
- bug: Last version 4.18.2 breaks unit test in the proyect. HOT 4
- bug: Test files copied to output target HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stencil.