Bird
0
0

Find the bug in this Cypress component test:

medium📝 Debug Q7 of 15
Cypress - Component Testing
Find the bug in this Cypress component test:
describe('InputField', () => {
  it('accepts text input', () => {
    cy.mount()
    cy.get('input').type('Hello')
    cy.get('input').should('have.value', 'Hello')
  })
})
AInputField component is not mounted properly
Bcy.get('input') selector is incorrect
CMissing import of cy.mount() from Cypress library
DAssertion should check 'contain.text' instead of 'have.value'
Step-by-Step Solution
Solution:
  1. Step 1: Check test setup

    InputField is used in JSX but no import statement, causing ReferenceError: InputField not defined.
  2. Step 2: Validate selectors and assertions

    cy.get('input') is correct, 'have.value' proper for input value; cy.mount syntax ok assuming setup.
  3. Final Answer:

    InputField component is not mounted properly -> Option A
  4. Quick Check:

    Import component before mounting [OK]
Quick Trick: Import the component before mounting it [OK]
Common Mistakes:
  • Assuming selector or assertion is wrong
  • Forgetting to import mount function
  • Confusing text content with input value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes