Bird
0
0

You want to run accessibility checks only for WCAG 2.1 AA rules on the entire page. Which is the correct way to do this in Cypress with cypress-axe?

hard📝 Application Q8 of 15
Cypress - Plugins and Ecosystem
You want to run accessibility checks only for WCAG 2.1 AA rules on the entire page. Which is the correct way to do this in Cypress with cypress-axe?
Acy.checkA11y({ runOnly: ['wcag21aa'] }) cy.injectAxe()
Bcy.injectAxe() cy.checkA11y(null, { runOnly: { type: 'tag', values: ['wcag21aa'] } })
Ccy.injectAxe({ runOnly: ['wcag21aa'] }) cy.checkA11y()
Dcy.checkA11y(null, { runOnly: ['wcag2a'] })
Step-by-Step Solution
Solution:
  1. Step 1: Understand how to specify rules in checkA11y

    The runOnly option accepts an object with type 'tag' and an array of tags like 'wcag21aa'.
  2. Step 2: Confirm correct command order and parameters

    First inject axe, then run checkA11y with null selector for whole page and correct options.
  3. Final Answer:

    cy.injectAxe() cy.checkA11y(null, { runOnly: { type: 'tag', values: ['wcag21aa'] } }) -> Option B
  4. Quick Check:

    Use runOnly with type and values for specific rules [OK]
Quick Trick: Use runOnly with type 'tag' and values array for WCAG rules [OK]
Common Mistakes:
  • Passing runOnly to injectAxe instead of checkA11y
  • Using incorrect runOnly format
  • Running checkA11y before injectAxe

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes