Challenge - 5 Problems
Responsive Breakpoint Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2: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);
Attempts:
2 left
💡 Hint
The first number in cy.viewport(width, height) is the width in pixels.
✗ Incorrect
The cy.viewport command takes width as the first argument and height as the second. So cy.viewport(768, 1024) sets the viewport width to 768 pixels.
❓ assertion
intermediate2: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?
Attempts:
2 left
💡 Hint
The window object has the innerWidth property representing viewport width.
✗ Incorrect
cy.window() gets the window object, and its('innerWidth') accesses the viewport width. The assertion checks if it equals 375.
🔧 Debug
advanced2: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');
Attempts:
2 left
💡 Hint
Menus often collapse into a hamburger icon on small screens.
✗ Incorrect
On small viewports like iPhone 6, menus are often hidden and toggled by a button. The test fails because it expects the menu visible without clicking the toggle.
❓ framework
advanced2: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?
Attempts:
2 left
💡 Hint
Cypress supports device presets with optional orientation argument.
✗ Incorrect
The 'ipad-2' preset with 'landscape' orientation sets the viewport to tablet landscape size.
🧠 Conceptual
expert2: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?
Attempts:
2 left
💡 Hint
Think about how websites change layout on phones, tablets, and desktops.
✗ Incorrect
Websites use CSS breakpoints to adjust layout and features based on viewport width. Testing multiple widths ensures all layouts work correctly.