Bird
0
0

This Cypress test fails with a syntax error:

medium📝 Debug Q7 of 15
Cypress - Plugins and Ecosystem
This Cypress test fails with a syntax error:
cy.visit('/settings')
cy.injectAxe()
cy.checkA11y('#form', { runOnly: ['wcag2a'] }

What is the error?
AYou cannot pass options to <code>cy.checkA11y</code>.
BThe <code>runOnly</code> option is invalid and causes the error.
CMissing closing parenthesis for the <code>cy.checkA11y</code> command.
DThe selector '#form' is not allowed in <code>cy.checkA11y</code>.
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax of cy.checkA11y call

    The command has an opening parenthesis but no matching closing parenthesis at the end.
  2. Step 2: Validate option usage

    The runOnly option is valid, and selectors are allowed, so the error is due to syntax.
  3. Final Answer:

    Missing closing parenthesis for the cy.checkA11y command. -> Option C
  4. Quick Check:

    Always close parentheses in command calls [OK]
Quick Trick: Check for matching parentheses in commands [OK]
Common Mistakes:
  • Assuming options are invalid
  • Thinking selector is disallowed
  • Ignoring syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes