Bird
0
0

What will be the output when running this Cypress test?

medium📝 Predict Output Q4 of 15
Cypress - Writing Tests
What will be the output when running this Cypress test?
it('checks button text', () => { cy.get('button').should('have.text', 'Submit') })
ATest passes if the button text is exactly 'Submit'
BTest passes if the button contains the word 'Submit' anywhere
CTest fails if the button text is 'Submit'
DTest throws a syntax error
Step-by-Step Solution
Solution:
  1. Step 1: Understand the assertion used

    The assertion should('have.text', 'Submit') checks for exact text match.
  2. Step 2: Determine test pass condition

    The test passes only if the button's text exactly equals 'Submit'. Partial matches fail.
  3. Final Answer:

    Test passes if the button text is exactly 'Submit' -> Option A
  4. Quick Check:

    have.text means exact text match [OK]
Quick Trick: Use have.text for exact text match, not partial [OK]
Common Mistakes:
  • Assuming partial text match with have.text
  • Confusing have.text with contain
  • Expecting syntax errors from correct code

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes