I'm trying to capture screenshots for various viewport sizes. At points during each test, I call a custom Cypress command, which loops over an array of viewport sizes to update the viewport and take the screenshot.
Cypress.Commands.add('responsiveScreenshots', function (customLabel) {
const { title } = this.test;
if (customLabel) {
title += ` - ${customLabel}`;
}
const sizes = [
{ w: 375, h: 667 },
{ w: 768, h: 1024 },
{ w: 1280, h: 800 }
];
cy.get('.notification-manager').invoke('css', 'position', 'absolute');
sizes.forEach((size) => {
const filename = `${title}/${size.w}x${size.h}`;
cy.viewport(size.w, size.h);
cy.screenshot(filename, {
scale: true,
capture: 'fullPage'
});
});
cy.get('.notification-manager').invoke('css', 'position', null);
});
Here is an example of the sort of screenshot I'm getting:

I'm expecting something more like this:

I haven't mocked up the notification so ignore that, but clearly something is wrong.
This happens in both headless and headed modes.
Bug?
I'm not sure if this is the correct approach to this problem. I will be using these screenshots for visual regression testing, so they need to look correct.
I can confirm, we get the same when doing this.
Fix this already!!!
I managed to fix it by removing the scale option, so cy.screenshot('testFullScreen', { capture: 'fullPage' }); works perfectly with me
I can reproduce this with the code below. Removing the scale: true option fixes the issue.
<html>
<body>
<div style="background: linear-gradient(yellow, blue, red); height: 1000px; width: 400px">foo</div>
</body>
</html>
it('Take screenshot', () => {
cy.visit('index.html')
cy.screenshot({
scale: true,
})
})


Most helpful comment
I can confirm, we get the same when doing this.