-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add Shadow DOM support to @percy/dom #280
Comments
Forgot to mention: there's a similar issue with Cypress snapshots (shown on hover) not including shadow-dom: There's a repo linked there that makes it easy to repro. |
Thanks for the issue! This is currently not supported across all of our SDKs. In the near future we'll be picking this up now that there's a method for capturing open shadowroots in the DOM: https://web.dev/declarative-shadow-dom/#serialization But it does require a complete refactor to how |
I'd like to +1 this too. We started out with |
@Robdel12 That's great news. I have confirmed that Cypress supports this already with the following change (when using Chrome browser, but not yet Electron): on("before:browser:launch", (browser = {}, launchOptions) => {
launchOptions.args.push("--enable-experimental-web-platform-features");
return launchOptions;
}); Can you confirm that doesn't help until percy-dom knows what to do with Also, if you have ideas for workarounds, that would really help my team. |
Sadly there isn't anything that can be done until we do the work to update |
Did some preliminary research on this with Chrome 90 recently out with the declarative API enabled by default.
Even when support is more widely available and that isn't an issue, we'll still have to figure out the first issue of how to properly serialize shadow root trees. Maybe that involves an even bigger refactor to walking the DOM tree and building the clone ourselves, but that's an even larger task than refactoring to use |
Just checking if there's been any progress here at all? |
Hey @jeffchew! Based on @wwilsman's research (the comment right above) it doesn't look like this will be something we'll be able to implement for a while. The web APIs just aren't there and what is starting to come out only works/exists in Chrome (behind flags, depending on what version your tests are running in, default in Chrome 90). We'd love to support this but it seems to be a case of Google running out in front of everyone (other browser vendors). |
) ### Related Ticket(s) Refs #6139 ### Description This PR fully moves the existing `test-e2e` package to a dedicated cypress test setup for web components and react storybooks. A few tests have been included for `masthead`, `locale-modal`, and `leadspace`. They are largely focused on snapshot testing, though percy has been disabled for now as rendering of dynamic states are still not supported in percy for web components (see percy/cli#280). Actual cypress tests can be created now though, and also the current tests uses the built-in cypress screenshot feature: ![image](https://user-images.githubusercontent.com/1641214/132697052-2943ccdf-81c5-450d-999e-c39e557a3d05.png) And video that shows how the tests are run: https://user-images.githubusercontent.com/1641214/132697174-a778c055-d3d8-4e01-877d-bd58c2aa7491.mp4 ### Changelog **New** - Cypress testing for web components and react storybook **Changed** - disabled video recording by default to speed up tests **Removed** - Removed `test-e2e` package
Just keeping this on the radar if possible. We are increasing our e2e test coverage on our end and so far can only test with React (which we plan to deprecate sometime in the future and only support web components). |
Just another FYI, we tried upgrading All snapshots are unstyled, and a number of them also just went missing. |
You'll want to re-enable JavaScript with Storybook & WC's. https://github.com/percy/percy-storybook#unexpected-diffs Edit: FWIW, there won't be any progress on this until the Web's APIs for WC's matures (as described here.) |
all: revert
melink14/rikaikun#933
Hey Percy folks! Shadow DOM support is important for us at Addepar because our design system is based on Stencil which makes heavy use of shadow DOM. We've developed a fork of @percy/cli (and to a smaller extent @percy/ember) that supports shadow DOM. They're publicly accessible at https://github.com/Addepar/percy-cli and https://github.com/Addepar/percy-ember. We've open sourced the forks as a proof of concept for the developers of Percy, as well as for other Percy users to use if they are in a similar situation as us. Here are some details of the implementation. I'm happy to answer any questions. CaveatsAs discussed in the comments above, we're leaning on the experimental Declarative Shadow DOM available in Chrome. This means that:
Implementation notescloneNode
adoptedStylesheetsThe It's a known issue that We resolve this issue by inlining a |
@mmun That's amazing, thanks for looking into this. At @OTA-Insight we're in the exact same situation as the design system is built with Stencil using Shadow DOM and the main application is written in Ember. Not having Shadow DOM available in the screenshot is blocking us from adopting Percy. I've tested our setup using the forks you've linked and it fixes the issue 🙌 Right now the forks are built locally. When linking them directly in
It would be great if this could make its way to the official package. |
@IgnaceMaes Yeah, we're still thinking about the best way to handle this. One option is to use something like https://gitpkg.vercel.app/. As an aside, you'll probably run into a Stencil-specific bug ("Sharing constructed stylesheets in multiple documents is not allowed") with the current implementation. This will cause your tests to fail despite the screenshots uploading correctly. We'll add a workaround for that soon. |
👋🏼 Thanks for the info @mmun! We'll likely only be interested in accepting something like this behind a flag so it's opt-in. There's too many caveat's for us to go all in on this, the API will need to stabilize a lot more before we feel ready for that. |
I mean, the caveat today is that Percy doesn't work with Web Components (w/ Shadow DOM) rendered by a JS framework (or maybe generally) at all, which seems like a pretty large caveat. Regardless, your call over at Percy 👍. What does adding this functionality behind an opt-in flag look like? Is there prior art or an example? We would love to have this upstream even if it is opt-in so that we can get off our forks. |
That fork does look promising! We'll look into adopting this officially behind a config option in the coming weeks. Currently, the only option that gets forwarded to the DOM serialization script is |
@wwilsman Awesome. Thanks for taking a look. My team is available to collaborate if needed. |
Would love this as a config option! Thank you @mmun for the work you put into your project for this! This would hopefully unblock us on our end! |
@jeffchew with storybook you can enable JS safely and it will render the story from scratch in our browsers (so the shadow DOM will get built). It's the only SDK that this will work well with |
Thank you @Robdel12 , it turns out after digging into the storybook side there might be an unrelated issue to this that we are still blocked by, but we are also using percy with e2e testing in Cypress where we currently cannot do with web components (which relates more to this issue). The unrelated bug with storybook seems to also affect our React based storybook, where most snapshots are not rendering (there is a timeout error of some kind) and I already reached out to our account executive and Lee V. about this (but not sure if there is an issue open for this). |
Ah! @jeffchew I remember debugging this and shipping a feature to help. I remember there were ad requests that were hanging asset discovery up (or maybe tracking pixels). You can exclude those requests from asset discovery and that should hopefully stop the timeouts from happening on your storybook builds https://docs.percy.io/docs/debugging-sdks#disallowing-requests |
Thanks @Robdel12 ! We did try that but still running into issues. Should I create a new issue to track this as this is different from the Shadow DOM support? I can share logs on what I'm seeing but looks like JS assets themselves are getting blocked in Percy. |
For sure! I'd open a support discussion on the storybook SDK |
@Robdel12 issue opened! percy/percy-storybook#565 |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
Hey folks! we've shadow DOM capturing in our roadmap. Due to some OKR reshuffling, it was delayed. Please expect beta by earlier Jan 2023. To workaround this till then you may enable javascript in Percy's config and use https://github.com/percy/percy-storybook/ SDK. |
Hey folks! Percy now supports capturing Shadow DOM available in the Alpha release of CLI 🏗️. Please refer to this documentation for trying it out. |
Nothing rendered in the shadow-dom, even if open, shows up in percy-cypress snapshots.
The below cypress test passes fine.
Repo:
The outerHTML logged out does not include the text, and apparently that's how percy gets the DOM...
Any suggestions on workarounds? Getting rid of shadow-dom is not an option for my application.
The text was updated successfully, but these errors were encountered: