Complete the code to take a screenshot for visual regression testing.
cy.visit('https://example.com') cy.[1]('homepage')
The screenshot command captures the current page view for visual regression testing.
Complete the code to compare the current screenshot with the baseline image.
cy.matchImageSnapshot([1])The matchImageSnapshot function takes a name string to identify the snapshot, usually without file extension.
Fix the error in the code to properly set the viewport size for visual regression testing.
cy.viewport([1], 800)
The viewport width must be a number, not a string.
Fill both blanks to create a dictionary of viewport sizes and filter only those wider than 500 pixels.
const viewports = { 'small': 320, 'medium': 768, 'large': 1024 };
const filtered = Object.entries(viewports).filter(([[1], [2]]) => [2] > 500);When filtering entries, the first element is the key and the second is the value.
Fill all three blanks to create a test that visits a page, sets viewport, and takes a snapshot named 'homepage'.
describe('Visual test', () => { it('checks homepage', () => { cy.visit([1]) cy.viewport([2], 800) cy.screenshot([3]) }) })
The test visits the full URL, sets viewport width as a number, and names the screenshot 'homepage'.