Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOM Snapshots don't include Shadow DOM #8843

Open
yjaaidi opened this issue Oct 14, 2020 · 18 comments
Open

DOM Snapshots don't include Shadow DOM #8843

yjaaidi opened this issue Oct 14, 2020 · 18 comments
Labels
E2E Issue related to end-to-end testing prevent-stale mark an issue so it is ignored by stale[bot] topic: shadow dom Issues when testing shadow dom Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: feature New feature that does not currently exist

Comments

@yjaaidi
Copy link

yjaaidi commented Oct 14, 2020

Current behavior

  1. Setting includeShadowDom to true allows accessing Shadow DOM but when debugging previous commands DOM snapshots, Shadow DOM is missing.
  2. Visual regression tools like Percy fail because Shadow DOM is missing.

Related issues: #144 #830 #5776

Desired behavior

DOM Snapshots should somehow include Shadow DOM.

Test code to reproduce

Please let me know if you really need a repro or if the given information is enough.

Versions

Cypress: 5.3.0
@percy/cypress: 2.3.2

@jennifer-shehane
Copy link
Member

Please provide a reproducible example of the issue where DOM snapshots are not present within Cypress alone, isolating the issue outside of Percy.

We’ll have to close the issue if this is not provided. Thanks.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Oct 14, 2020
@yjaaidi
Copy link
Author

yjaaidi commented Oct 15, 2020

Thank you Jennifer for your quick feedback. I'll come up with a repro as soon as I can.

@yjaaidi yjaaidi changed the title DOM Snapshots don't incode Shadow DOM DOM Snapshots don't include Shadow DOM Oct 28, 2020
@yjaaidi
Copy link
Author

yjaaidi commented Oct 28, 2020

Hi @jennifer-shehane!
Here is a repro of the issue https://github.com/yjaaidi/cypress-snapshot-shadow-dom-repro

As you can see in the GIF below, the Shadow DOM appears when inspecting the DOM but it doesn't appear when inspecting the DOM Snapshot.

cypress-snapshot-shadow-dom

@jennifer-shehane jennifer-shehane added the topic: shadow dom Issues when testing shadow dom label Oct 28, 2020
@jennifer-shehane
Copy link
Member

Thanks for providing a reproducible example. I can see this issue from this repo: https://github.com/yjaaidi/cypress-snapshot-shadow-dom-repro

During .pause() the DOM element is rendered

Screen Shot 2020-10-28 at 6 06 41 PM

During snapshot, the DOM element is not rendered

Screen Shot 2020-10-28 at 6 06 55 PM

@cypress-bot cypress-bot bot added stage: ready for work The issue is reproducible and in scope and removed stage: needs information Not enough info to reproduce the issue labels Oct 28, 2020
@yjaaidi
Copy link
Author

yjaaidi commented Oct 28, 2020

Exactly! Thank you for the screenshots 😉

@yjaaidi
Copy link
Author

yjaaidi commented Oct 29, 2020

This might help

There is a new experimental feature in Chrome that allows recursive Shadow DOM serialization (it is hidden behind the chrome://flags/#enable-experimental-web-platform-features feature flag).

document.body.getInnerHTML({includeShadowRoots: true})

Meanwhile it lands, we could use a polyfill.

@distante
Copy link

Hi, I do not quite understand which is the actual state of this issue.

As I understand using includeShadowDom will allow us to find shadow DOM elements but it does not have any effect on the Snapshots and they are still blank. Is this correct?

I also get blank snapshots but I see how the DOM renders while testing using Cypress 7.7.0

@jennifer-shehane
Copy link
Member

@distante This is correct. If you hover over the commands that were done on Shadow DOM, it will not restore how the DOM looked at that time.

@DHFW
Copy link

DHFW commented Jan 11, 2022

@jennifer-shehane @bahmutov Any plans to fix this (if possible)? This makes testing in Cypress with shadow DOM / web components so much less useful (using the Cypress UI)... Also: cy.type() in normal inputs/textarea fails because according to Cypress the element is disabled, while it does not have such an attribute. Almost every action (type, click, blur) needs the {force: true} option else it will not work. This is totally different from the normal/non-shadow DOM way of working...

@swinejelly
Copy link

Yes, we are also affected by this as well and cannot test a component that relies heavily on using shadow doms short of heavily changing it.

@mrrinatino
Copy link

This is a problem that I recently encountered on my project. In the development of simple scenarios, this did not hurt much. But when I started describing more sophisticated test cases, it was very inconvenient in some places because of the existing problem. I would be grateful for the solution.

@cypress-bot cypress-bot bot added stage: backlog and removed stage: ready for work The issue is reproducible and in scope labels Apr 29, 2022
@papb
Copy link

papb commented Aug 19, 2022

Hello! How can I help moving this issue forward? @jennifer-shehane could you point me to where I should I look in Cypress' source code so that I can do a PR?

@nordp
Copy link

nordp commented Nov 9, 2022

@jennifer-shehane This is something that heavily affects debugability of cypress tests on apps that use shadow DOMs. Testing works fine, but debugging or developing tests is a lot more difficult when the snapshot feature is not useable.

@nagash77 nagash77 added the prevent-stale mark an issue so it is ignored by stale[bot] label Apr 3, 2023
@papb
Copy link

papb commented May 5, 2023

Hello! How can I help moving this issue forward? @jennifer-shehane could you point me to where I should I look in Cypress' source code so that I can do a PR?

@papb
Copy link

papb commented May 5, 2023

For the record, I still have this issue with Cypress v10.11.0

@nagash77 nagash77 added E2E Issue related to end-to-end testing Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. labels May 8, 2023
@matheuscnali
Copy link

I also have this issue!

@ashleynolan
Copy link

Is there any news on this issue? We'd be keen to hear if there was any way we could help with the issue, as otherwise we'll essentially either have to move away from either Cypress or Percy in order to give us visual regression snapshots

@mcditermine
Copy link

Having the same issue. Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing prevent-stale mark an issue so it is ignored by stale[bot] topic: shadow dom Issues when testing shadow dom Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. type: feature New feature that does not currently exist
Projects
None yet
Development

No branches or pull requests