percy / percy-cypress

Visual testing with Cypress and Percy
https://percy.io
MIT License
346 stars 40 forks source link

Snapshot ignores the passed `scope` and renders the whole screen #620

Closed eskimoblood closed 1 year ago

eskimoblood commented 1 year ago

The problem

I try to get scope option work but I only get the whole screen as a snapshot not the part I pass as selector to scope.

Environment

Details

The following code first checks that the element is in the DOM and then use the same selector to set the scope for percy:

cy.get('[data-cy=signalBarChartWidget]').should( 'exist')
cy.percySnapshot('bar chart', {scope: '[data-cy=signalBarChartWidget]'})

When I download the html of the snapshot from percy and open it in a browser I can find the element by document.querySelector('[data-cy=signalBarChartWidget]')

image

Debug logs

[percy:core:snapshot] Received snapshot: bar chart (0ms)
[percy:core:snapshot] - url: https://localhost:8080/g/statics (0ms)
[percy:core:snapshot] - scope: [data-cy=signalBarChartWidget] (0ms)
[percy:core:snapshot] - widths: 1280px (1ms)
[percy:core:snapshot] - minHeight: 1024px (0ms)
[percy:core:snapshot] - disableShadowDOM: false (0ms)
[percy:core:snapshot] - discovery.allowedHostnames: localhost (0ms)
[percy:core:snapshot] - discovery.requestHeaders: {"Cookie":" ###; token=$$$; identifier=&&&; login=---"} (0ms)
[percy:core:snapshot] - discovery.disableCache: false (0ms)
[percy:core:snapshot] - clientInfo: @percy/cypress/3.1.1 (0ms)
[percy:core:snapshot] - environmentInfo: cypress/12.3.0 (0ms)
[percy:core:snapshot] - domSnapshot: true (0ms)
itsjwala commented 1 year ago

@eskimoblood can you provide the snapshot/build ID which was created from the above run?

Please check this further @samarsault.

eskimoblood commented 1 year ago

I had rewritten the test and now if I try to use scope I can't reproduce the issue anymore. I will give some more tries and close the ticket if I can't reproduce til tomorrow.

itsjwala commented 1 year ago

Closing this issue.

Please reopen and share reproducible steps or reach out to our Support if you may need any assistance.