Closed DesignByOnyx closed 4 years ago
After more testing, there are several problems with the "shadowFind" method which I will just tack onto this:
$.find
returns the results from multiple contexts ("subjects"), whereas the shadowFind
currently only uses the first context/subject.shadowFind
method does not allow descendant selectors (eg. spaces in the selector). This too breaks the semantics of $.find
and breaks the ability for Cypress to retry the last commandshadowFind
uses the native querySelectorAll
which returns a NodeList, and this breaks Cypress default "retry" logic. Looking at the internals of Cypress, it expects a jQuery collection in order to continue retrying.I have a PR which fixes all the mentioned problems coming in a minute.
Hi @DesignByOnyx Thanks for the contribution!
Your approach seems to be straightforward and elegant, just merged that.
As for tests that I have in ./example
, retry-ability for dynamically added DOM element fails, so I think some piece is missing in your implementation. Not sure, but this might be related to shadowContains
Can you please take a look on that as well? I don't have any opportunity to take a look.
Fixing this allows me to release this change! 🥂
@all-contributors add @DesignByOnyx for ideas, code
Thanks for merging this. I definitely feel this is a step in the right direction and I am committed to making this stronger. I am currently integrating "proper" tests and want to provide a way to test multiple web component libraries: polymer/lit, svelte, stenciljs, etc. I'll take a look at the breaking example and provide a PR soon.
Current behavior:
First, thanks so much for the work on this.
I am using StencilJS and Ionic to build a component library, and I'm working with a simple component with a structure like this where everything inside
stls-custom-component
is within a shadow dom and theion-item
renders slotted content within its own shadow dom. I am unable to select anion-button
from the context of its parention-item
.I am using the following commands:
Desired behavior:
The problem is that the
shadowFind('ion-button')
is only searching in the shadowRoot on theion-item
, but the ion-button is in the light dom. To best describe the request I am making, consider the following elGetter:Steps to reproduce: (app code and test code)
I am glad to provide a repo if the above is insufficient - just let me know.
Versions
cypress@3.7.0 cypress-shadow-dom@1.2.1