Challenge - 5 Problems
Accessibility Master with cypress-axe
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
What does cypress-axe primarily test for?
cypress-axe is a tool used in Cypress tests. What is its main purpose?
Attempts:
2 left
💡 Hint
Think about what 'axe' is known for in web testing.
✗ Incorrect
cypress-axe integrates the axe-core accessibility engine into Cypress tests to check for accessibility issues on web pages.
📝 Syntax
intermediate2:00remaining
How to inject axe-core in a Cypress test?
Which code snippet correctly injects axe-core into the current page in a Cypress test?
Cypress
cy.visit('https://example.com') // inject axe-core here
Attempts:
2 left
💡 Hint
The function name starts with 'inject' and ends with 'Axe'.
✗ Incorrect
The correct command to inject axe-core is cy.injectAxe(). This prepares the page for accessibility checks.
❓ rendering
advanced2:00remaining
What is the output of this accessibility check?
Given this Cypress test code, what will be the result shown in the test runner if the page has no accessibility violations?
Cypress
cy.visit('https://example.com')
cy.injectAxe()
cy.checkA11y()Attempts:
2 left
💡 Hint
If the page is accessible and axe-core is injected, what should happen?
✗ Incorrect
If the page has no accessibility issues, cy.checkA11y() will pass silently without errors.
❓ selector
advanced2:00remaining
How to limit axe checks to a specific element?
Which option correctly runs accessibility checks only on the element with id 'main-content'?
Cypress
cy.visit('https://example.com') cy.injectAxe() // run check here
Attempts:
2 left
💡 Hint
Use a CSS selector for an id.
✗ Incorrect
To check accessibility on a specific element by id, use the CSS selector with a hash: #main-content.
❓ accessibility
expert2:30remaining
What accessibility issue does this axe violation report indicate?
If cypress-axe reports a violation with the rule 'color-contrast', what does it mean?
Attempts:
2 left
💡 Hint
Think about what 'color-contrast' refers to in accessibility.
✗ Incorrect
The 'color-contrast' rule means the text color and background color combination is too similar, making it hard to read for some users.