In Cypress component testing, components must be mounted using JSX syntax like cy.mount(<MyButton />), not just the component name.
Step 2: Verify other parts
The selector cy.get('button') and assertion are correct. cy.mount is valid in component tests.
Final Answer:
Missing JSX syntax when mounting component -> Option A
Quick Check:
Use JSX syntax in cy.mount() [OK]
Hint: Always wrap component in <> when mounting [OK]
Common Mistakes:
Passing component without JSX syntax to cy.mount
Thinking cy.mount is invalid in component tests
Misreading selector as incorrect
5. You want to test a login form component in isolation but also verify the full login flow including navigation. Which Cypress testing approach should you use for each task?
hard
A. Use component testing for form UI; use E2E testing for full login flow
B. Use E2E testing for form UI; use component testing for full login flow
C. Use only component testing for both tasks
D. Use only E2E testing for both tasks
Solution
Step 1: Match testing types to tasks
Component testing is best for isolated UI parts like the login form component itself.
Step 2: Use E2E for full app flow
To verify the entire login flow including navigation and backend, E2E testing is appropriate.
Final Answer:
Use component testing for form UI; use E2E testing for full login flow -> Option A