Bird
0
0

Identify the error in this test code:

medium📝 Debug Q6 of 15
Cypress - Plugins and Ecosystem
Identify the error in this test code:
cy.findByLabelText('Password').type('secret')
cy.findByRole('button', { name: 'Login' }).click()
cy.findByText('Welcome').should('exist')
ANo error; code is correct
BIncorrect role name 'button' should be 'btn'
CUsing findByText without specifying exact match option
DMissing await or .then() to handle asynchronous commands
Step-by-Step Solution
Solution:
  1. Step 1: Understand Cypress command chaining

    Cypress commands are asynchronous and chain automatically; no need for await or .then() in Cypress tests.
  2. Step 2: Identify the actual error

    There is no error in the code; role 'button' is correct; findByText works without exact option; commands chain properly.
  3. Final Answer:

    No error; code is correct -> Option A
  4. Quick Check:

    Cypress commands chain automatically; no await needed [OK]
Quick Trick: Cypress commands chain; no async/await needed [OK]
Common Mistakes:
  • Thinking Cypress needs await
  • Confusing role names
  • Assuming findByText needs exact option always

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes