Recall & Review
beginner
What are props in component testing?
Props are inputs passed to a component to control its behavior or display. They act like settings or instructions for the component.
Click to reveal answer
intermediate
How do you test if a component received the correct prop value in Cypress?
You can check the component's rendered output or attributes that depend on the prop. Cypress can also spy on functions to verify prop-driven behavior.
Click to reveal answer
beginner
What is an event in the context of UI testing?
An event is an action like a click, input, or submit that a user performs. Testing events means checking if the component reacts correctly to these actions.
Click to reveal answer
intermediate
How can Cypress test if an event handler was called when a button is clicked?
Use
cy.get() to find the button, then .click() to simulate the click. Use cy.spy() or cy.stub() to watch the event handler and assert it was called.Click to reveal answer
beginner
Why is testing props and events important in component testing?
Because props control what the component shows or does, and events are how users interact. Testing both ensures the component works as expected in real use.
Click to reveal answer
In Cypress, which command simulates a user clicking a button?
✗ Incorrect
You first select the element with cy.get(), then call .click() to simulate the click.
What does a
cy.spy() do in event testing?✗ Incorrect
cy.spy() watches a function to see if it was called during the test.
Which of these is a prop in component testing?
✗ Incorrect
Props are inputs like functions or values passed into components.
Why test events in UI components?
✗ Incorrect
Events represent user actions; testing them ensures the component responds properly.
Which Cypress command helps check if a prop affects the component output?
✗ Incorrect
cy.get() selects elements to assert their content or attributes changed by props.
Explain how you would test a button click event handler using Cypress.
Think about selecting the element, simulating the event, and verifying the response.
You got /4 concepts.
Describe why testing props is important and how you can verify them in Cypress tests.
Consider props as settings and how to check their effect.
You got /4 concepts.