Comments (5)
Hey @jarretmoses, thanks for the issue! I suspect something else is going on. It sounds like your apps DOM changes between widths? The way Percy works is by capturing the DOM of the page (and its state) when percySnapshot
is called. When then do asset discovery on the DOM & send it off to the API where its rendered concurrently across browsers & widths.
If your applications DOM changes when the browser is resized, this current method doesn't work. We render that same DOM at different widths with JS disabled (to prevent JS from altering any captured state). This method assumes the DOM stays the same and you're using CSS media queries entirely to alter the page.
To fix this you'll have to resize the test browser before calling percySnapshot
for accurate snapshots.
// A helper to make this easy, feel free to edit
Cypress.Commands.add('percyResponsiveSnapshot', (name, width, options = {}) => {
delete options.widths // we never want to use those in this helper
cy
// https://docs.cypress.io/api/commands/viewport.html#Syntax
.viewport(width)
.percySnapshot(`${name} - ${width}`, { widths: [width], ...options })
// Set back the orignal width if you'd like
//.viewport()
});
// usage:
cy.percyResponsiveSnapshot('Homepage', 320)
from percy-cypress.
@Robdel12 thanks a lot for the response. You are exactly correct and what you suggest makes a lot of sense and I will give it a shot.
from percy-cypress.
Hey, just wanted to say thanks for the answer, it pinpointed my issue perfectly.
Is it really not possible to group those snapshots in Percy when manually changing the viewport with Cypress?
I'm trying to convince my company to use Percy, and this is probably a deal-breaker 😢
from percy-cypress.
I tried this on 4.11.0 (cypress) + 2.3.1 (@percy/cypress) and ran into an issue where the cy.viewport command expects either a width and height integer, or a preset string like 'macbook-13' while puppeteer, which is used by percy still expects a width integer. So the above did not work for me. I ended up having to pass the preset string to the cy.viewport command and an integer to the percySnapshot command.
from percy-cypress.
This issue is stale because it has been open for more than 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.
from percy-cypress.
Related Issues (20)
- How to select Approved build as base build?
- Webpages behind Netlify Authentication not showing css in Percy snapshot
- [TypeScript] percySnapshot - TypeError: Cannot read properties of undefined (reading 'isTTY') HOT 19
- [Cypress regression]`TypeError: data.hasOwnProperty is not a function` HOT 12
- [percy] Fails to take dom snapshot
- Does percy with cypress support visual testing of shadow dom elements? HOT 1
- `cy.percySnapshot()` not uploading screenshots when used via `browserstack-cypress` HOT 1
- Percy does not work for Cypress component testing
- Cannot read properties of undefined (reading 'isServer') HOT 9
- SyntaxError: Unexpected identifier HOT 2
- Test is marked as successful, but `Could not take DOM snapshot` error is present.
- The term 'percy' is not recognized as the name of a cmdlet
- Duplicate snapshot name in a parallel build causes missing snapshots HOT 13
- Need the ability to set width and height for screenshots HOT 2
- Snapshot ignores the passed `scope` and renders the whole screen HOT 3
- Percy no longer captures embedded pdf viewer since Cypress v12.15.0 and above HOT 4
- Uncaught error was detected outside of a test: No commands were issued in this test HOT 3
- Specifying "width" instead of "widths" in percySnapshot HOT 4
- Cannot finalize before all snapshots have comparisons created HOT 2
- Images not captured by percy with cypress v13.6.4 HOT 12
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 percy-cypress.