Bird
0
0

You want to test a Vue component AlertBox that accepts a slot for custom message content. Which is the correct way to mount it with a slot containing <p>Warning!</p> in Cypress?

hard📝 Application Q15 of 15
Cypress - Component Testing
You want to test a Vue component AlertBox that accepts a slot for custom message content. Which is the correct way to mount it with a slot containing <p>Warning!</p> in Cypress?
Acy.mount(AlertBox, { slot: '<p>Warning!</p>' })
Bcy.mount(AlertBox, { props: { default: '<p>Warning!</p>' } })
Ccy.mount(AlertBox, { slots: { default: '<p>Warning!</p>' } })
Dcy.mount(AlertBox, { children: '<p>Warning!</p>' })
Step-by-Step Solution
Solution:
  1. Step 1: Understand slot passing in Cypress mount

    Slots are passed using the slots option with keys for slot names.
  2. Step 2: Check each option

    Only cy.mount(AlertBox, { slots: { default: '

    Warning!

    ' } }) correctly uses slots: { default: '

    Warning!

    ' }
    syntax.
  3. Final Answer:

    cy.mount(AlertBox, { slots: { default: '<p>Warning!</p>' } }) -> Option C
  4. Quick Check:

    Slots passed via slots object [OK]
Quick Trick: Use slots: { default: '' } to pass slot content [OK]
Common Mistakes:
  • Passing slot content as props
  • Using wrong option names like slot or children
  • Not wrapping slot content in slots object

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes