0
0
Cypresstesting~20 mins

Responsive breakpoint testing in Cypress - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Responsive Breakpoint Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the viewport width after this Cypress command?
Consider the following Cypress test code snippet that sets the viewport size. What will be the width of the viewport after running this command?
Cypress
cy.viewport(768, 1024);
A375 pixels
B1024 pixels
C800 pixels
D768 pixels
Attempts:
2 left
💡 Hint
The first number in cy.viewport(width, height) is the width in pixels.
assertion
intermediate
2:00remaining
Which assertion correctly checks if the viewport width is 375px?
You want to write a Cypress assertion to verify the viewport width is exactly 375 pixels. Which option is correct?
Acy.window().its('innerWidth').should('eq', 375);
Bcy.viewport().should('have.width', 375);
Ccy.get('body').should('have.css', 'width', '375px');
Dcy.document().should('have.property', 'width', 375);
Attempts:
2 left
💡 Hint
The window object has the innerWidth property representing viewport width.
🔧 Debug
advanced
2:00remaining
Why does this test fail on mobile viewport?
This Cypress test fails when run with cy.viewport('iphone-6'). What is the most likely reason?
Cypress
cy.viewport('iphone-6');
cy.get('.menu').should('be.visible');
AThe '.menu' element is hidden by default on small screens and requires a button click to show.
BThe 'iphone-6' viewport preset is invalid and causes viewport size to be zero.
CThe '.menu' selector is incorrect and does not match any element.
DCypress cannot simulate mobile devices and always uses desktop viewport.
Attempts:
2 left
💡 Hint
Menus often collapse into a hamburger icon on small screens.
framework
advanced
2:00remaining
Which Cypress command sets viewport to simulate a tablet in landscape mode?
You want to test your app on a tablet device in landscape orientation using Cypress. Which command correctly sets this viewport?
Acy.viewport(768, 1024);
Bcy.viewport('ipad-2', 'portrait');
Ccy.viewport('ipad-2', 'landscape');
Dcy.viewport('tablet', 'landscape');
Attempts:
2 left
💡 Hint
Cypress supports device presets with optional orientation argument.
🧠 Conceptual
expert
2:00remaining
Why is testing multiple breakpoints important in responsive testing?
In responsive testing, why should you test your web app at multiple viewport widths instead of just one?
ABecause testing one viewport width automatically covers all others due to CSS inheritance.
BBecause different viewport widths trigger different CSS breakpoints that change layout and functionality.
CBecause viewport width does not affect layout, only device type matters.
DBecause Cypress requires multiple viewport sizes to run tests successfully.
Attempts:
2 left
💡 Hint
Think about how websites change layout on phones, tablets, and desktops.