meinaart / cypress-plugin-snapshots

Plugin for snapshot tests in Cypress.io
MIT License
497 stars 118 forks source link

`clip` argument isn't honored in `toMatchImageSnapshot()` #152

Open shobhitg opened 4 years ago

shobhitg commented 4 years ago

Describe the bug

I have this following code:

cy.get('.mapboxgl-canvas').toMatchImageSnapshot({ capture: 'viewport', clip: { x: 0, y: 0, width: 100, height: 100 } });

The screenshot I get is full screen and not a clip. I think this may be a bug.

To Reproduce

Just use the clip arg in toMatchImageSnapshot() function, see that resulting image is not clipped, but rather a full screen image.

.toMatchImageSnapshot({ capture: 'viewport', clip: { x: 0, y: 0, width: 100, height: 100 } 

Expected behavior Expected behavior is that we should see a clipped image in the __image_screenshots__ folder.

Desktop (please complete the following information):

Mac OS version: 10.15.4

Cypress Versions:

    "cypress": "^5.3.0",
    "cypress-plugin-snapshots": "^1.4.4",
oliver-heeger commented 4 years ago

@shobhitg You should use: .toMatchImageSnapshot({ capture: 'viewport', screenshotConfig: { clip: { x: 0, y: 0, width: 100, height: 100 } } })

shobhitg commented 4 years ago

Thanks, this worked. However example code in Readme.md is incorrect. Just pointing out.

shobhitg commented 4 years ago

Created a PR, super minor thing. But will help people who come after me.