Resource library

QA How-To

Accessibility testing with Cypress (2026)

Learn accessibility testing with Cypress using cypress-axe, focused WCAG checks, keyboard scenarios, CI reporting, triage, and maintainable test design.

16 min read | 3,008 words

TL;DR

accessibility testing with Cypress works best as a risk-based workflow: define the contract, create isolated conditions, execute with supported APIs, assert observable outcomes, and preserve diagnostic evidence.

Key Takeaways

  • Start accessibility testing with Cypress with an explicit risk and observable success condition.
  • Use deterministic setup and unique test data so parallel results remain trustworthy.
  • Prefer stable public APIs and selectors over timing guesses or implementation details.
  • Preserve enough evidence to classify product, test, data, and environment failures.
  • Keep release gates small, fast, owned, and focused on critical behavior.
  • Review automation alongside manual and exploratory coverage.

accessibility testing with Cypress gives working QA engineers a practical path from initial setup to trustworthy delivery evidence. This guide answers what to configure, what to test, how to avoid false confidence, and how to explain the approach in an interview.

The examples favor supported, version-stable APIs and explicit assertions. Adapt URLs, selectors, data, and risk priorities to your product rather than copying a demo unchanged.

TL;DR

  • Define the behavior and evidence before automating it.
  • Keep setup deterministic, data isolated, and assertions observable.
  • Use supported APIs, preserve failure artifacts, and review flaky results as defects.
  • Combine automation with the human testing that the tool cannot perform.
Method Good at Cannot prove alone
axe in Cypress Repeatable rule detection Full WCAG conformance
Keyboard scenarios Focus and operability flows Screen reader usability
Manual review Meaning and interaction quality Continuous regression coverage
User research Real barriers and context Every release state

1. accessibility testing with Cypress: Set the Right Accessibility Testing Scope

Automated checks detect many deterministic markup and relationship problems, but they cannot judge every WCAG success criterion or the quality of an experience. Use Cypress for repeatable page-state checks, then add keyboard, screen reader, zoom, and human review.

Define supported pages, components, browsers, standards, impact levels, and exception ownership before turning violations into a release gate.

Frame set the right accessibility testing scope as a product decision. List supported users, environments, failure impact, and ownership. A small proof of concept should exercise one real workflow and one deliberate failure. Compare the clarity of the failure output, local developer experience, CI behavior, and maintenance burden. Record the decision so the team can revisit it when browser support or architecture changes.

For this part of accessibility testing with Cypress, define a representative success path, a meaningful rejection path, and a boundary condition. State the precondition, action, observable result, and cleanup for each. Use unique data when workers can overlap. On failure, retain the expected state plus the browser, network, console, or event evidence that can separate a product defect from a test defect.

Consider the section complete only when the check fails for the intended regression, passes for correct behavior, survives repeated and reordered execution, and produces a message another engineer can act on. Review that standard when the interface, environment, ownership, or delivery pipeline changes.

2. Install Cypress Axe Correctly

Install Cypress, axe-core, and cypress-axe as development dependencies. Import the commands once from the Cypress support file.

npm install --save-dev cypress axe-core cypress-axe
// cypress/support/e2e.ts
import "cypress-axe";

TypeScript users should ensure the package command types are included by the project configuration when editor discovery does not happen automatically.

Make setup reproducible from a clean checkout. Pin dependencies through the lockfile, document required environment variables, and keep secrets outside source control. A new contributor should be able to run one test without tribal knowledge. In CI, install exactly from the lockfile and print safe version information so an unexpected runtime change is visible in the job log.

For this part of accessibility testing with Cypress, define a representative success path, a meaningful rejection path, and a boundary condition. State the precondition, action, observable result, and cleanup for each. Use unique data when workers can overlap. On failure, retain the expected state plus the browser, network, console, or event evidence that can separate a product defect from a test defect.

Consider the section complete only when the check fails for the intended regression, passes for correct behavior, survives repeated and reordered execution, and produces a message another engineer can act on. Review that standard when the interface, environment, ownership, or delivery pipeline changes.

3. Run the First Accessibility Testing With Cypress Check

Visit a stable page, call cy.injectAxe(), then run cy.checkA11y(). Injection is required for each newly loaded document because axe runs in the application page.

describe("home accessibility", () => {
  it("has no detectable axe violations", () => {
    cy.visit("/");
    cy.injectAxe();
    cy.checkA11y();
  });
});

Read the example line by line before extending it. Identify which statement arranges state, which action triggers behavior, and which assertion proves the outcome. Then make the example fail intentionally. That red test confirms the assertion can detect the defect it claims to cover. Restore the behavior and run it several times to establish a useful baseline.

For this part of accessibility testing with Cypress, define a representative success path, a meaningful rejection path, and a boundary condition. State the precondition, action, observable result, and cleanup for each. Use unique data when workers can overlap. On failure, retain the expected state plus the browser, network, console, or event evidence that can separate a product defect from a test defect.

Consider the section complete only when the check fails for the intended regression, passes for correct behavior, survives repeated and reordered execution, and produces a message another engineer can act on. Review that standard when the interface, environment, ownership, or delivery pipeline changes.

4. Target Meaningful UI States

A single check at page load misses menus, dialogs, validation messages, tabs, and authenticated content. Drive the interface into each important state, then scan the relevant container or document.

cy.visit("/account");
cy.get("[data-testid=edit-profile]").click();
cy.get("[role=dialog]").should("be.visible");
cy.injectAxe();
cy.checkA11y("[role=dialog]");

Keep scope broad enough to catch relationships outside the component when relevant.

Treat every locator or identifier as an interface between the product and the test. Ask whether a redesign, translation, rerender, or duplicate component would change its meaning. Prefer a selector that communicates user intent or an explicit automation contract. When no stable contract exists, collaborate with developers instead of compensating with a long, fragile query.

For this part of accessibility testing with Cypress, define a representative success path, a meaningful rejection path, and a boundary condition. State the precondition, action, observable result, and cleanup for each. Use unique data when workers can overlap. On failure, retain the expected state plus the browser, network, console, or event evidence that can separate a product defect from a test defect.

Consider the section complete only when the check fails for the intended regression, passes for correct behavior, survives repeated and reordered execution, and produces a message another engineer can act on. Review that standard when the interface, environment, ownership, or delivery pipeline changes.

5. Configure Rules and Impact Deliberately

checkA11y accepts a context, axe options, a violation callback, and a skip-fail flag. Configure standards intentionally and document exclusions with an owner and expiry.

cy.injectAxe();
cy.checkA11y(null, { runOnly: { type: "tag", values: ["wcag2a", "wcag2aa", "wcag21aa", "wcag22aa"] } });

Tags select axe rules associated with those standards. Passing a tag set is not a claim of complete conformance.

Keep abstraction proportional to change. Extract a helper when it expresses a stable capability, has more than one credible caller, and improves failure readability. Avoid Boolean flags that make one method perform unrelated workflows. Tests should still reveal the business story without forcing a reviewer to jump through several files.

For this part of accessibility testing with Cypress, define a representative success path, a meaningful rejection path, and a boundary condition. State the precondition, action, observable result, and cleanup for each. Use unique data when workers can overlap. On failure, retain the expected state plus the browser, network, console, or event evidence that can separate a product defect from a test defect.

Consider the section complete only when the check fails for the intended regression, passes for correct behavior, survives repeated and reordered execution, and produces a message another engineer can act on. Review that standard when the interface, environment, ownership, or delivery pipeline changes.

6. Add Keyboard and Focus Scenarios

Cypress can verify focus movement and keyboard-operable behavior through key events, though real assistive technology testing remains separate. Check initial focus, logical order, visible focus, escape behavior, and restoration after a dialog closes.

cy.get("[data-testid=open-dialog]").click();
cy.get("[role=dialog]").should("be.visible");
cy.focused().should("have.attr", "data-testid", "dialog-title");
cy.get("body").type("{esc}");
cy.get("[role=dialog]").should("not.exist");
cy.get("[data-testid=open-dialog]").should("be.focused");

Data deserves the same engineering care as test code. Generate unique identities, create records through a supported boundary, and clean them up without hiding the primary failure. Separate credentials from scenario data. For destructive or billing-sensitive flows, use dedicated environments and accounts with explicit safeguards.

For this part of accessibility testing with Cypress, define a representative success path, a meaningful rejection path, and a boundary condition. State the precondition, action, observable result, and cleanup for each. Use unique data when workers can overlap. On failure, retain the expected state plus the browser, network, console, or event evidence that can separate a product defect from a test defect.

Consider the section complete only when the check fails for the intended regression, passes for correct behavior, survives repeated and reordered execution, and produces a message another engineer can act on. Review that standard when the interface, environment, ownership, or delivery pipeline changes.

7. Test Forms, Errors, and Dynamic Announcements

Verify every control has a programmatic name, instructions are connected, errors identify the field, and changes are announced appropriately. Axe catches some relationships, while focused assertions confirm application behavior.

Test submission with empty, invalid, and corrected values. Do not assert implementation details when a role, name, description, or focus outcome expresses the real accessibility contract.

Synchronization should describe the state transition. Name the event that ends waiting, such as a visible confirmation, enabled control, completed request, or persisted record. If no observable signal exists, improve the application or test seam. Raising a timeout can be valid for a known slow operation, but it is not a diagnosis.

For this part of accessibility testing with Cypress, define a representative success path, a meaningful rejection path, and a boundary condition. State the precondition, action, observable result, and cleanup for each. Use unique data when workers can overlap. On failure, retain the expected state plus the browser, network, console, or event evidence that can separate a product defect from a test defect.

Consider the section complete only when the check fails for the intended regression, passes for correct behavior, survives repeated and reordered execution, and produces a message another engineer can act on. Review that standard when the interface, environment, ownership, or delivery pipeline changes.

8. Report, Triage, and Prevent Regressions

A useful failure includes rule ID, impact, help URL, affected nodes, and enough DOM context to reproduce. Group duplicate violations by root component so teams fix the source rather than every instance.

Do not create a permanent baseline that silently accepts all existing violations. Ratchet down known debt, assign owners, and prevent new high-impact failures.

Debug from evidence rather than rerunning until green. Reproduce the smallest case, note the last completed command, inspect the expected element or event, and compare local and CI inputs. Classify the failure as product, automation, environment, or data. That classification guides ownership and exposes recurring systemic problems.

For this part of accessibility testing with Cypress, define a representative success path, a meaningful rejection path, and a boundary condition. State the precondition, action, observable result, and cleanup for each. Use unique data when workers can overlap. On failure, retain the expected state plus the browser, network, console, or event evidence that can separate a product defect from a test defect.

Consider the section complete only when the check fails for the intended regression, passes for correct behavior, survives repeated and reordered execution, and produces a message another engineer can act on. Review that standard when the interface, environment, ownership, or delivery pipeline changes.

9. Run Accessibility Checks in CI

Run a small critical-state suite on pull requests and broader scans on a schedule. Preserve screenshots, videos when enabled, console output, and structured violation data.

Keep the gate deterministic. Third-party content, personalization, consent banners, and animations may need controlled fixtures rather than blanket exclusions.

Design CI feedback for a person who did not write the test. Show the failing expectation, environment, browser, relevant log, and artifact location. Keep the required gate focused on critical journeys and move broad matrices to scheduled jobs when runtime would block delivery. Parallel execution must be matched by isolated records and accounts.

For this part of accessibility testing with Cypress, define a representative success path, a meaningful rejection path, and a boundary condition. State the precondition, action, observable result, and cleanup for each. Use unique data when workers can overlap. On failure, retain the expected state plus the browser, network, console, or event evidence that can separate a product defect from a test defect.

Consider the section complete only when the check fails for the intended regression, passes for correct behavior, survives repeated and reordered execution, and produces a message another engineer can act on. Review that standard when the interface, environment, ownership, or delivery pipeline changes.

10. accessibility testing with Cypress: Build a Complete Accessibility Testing Practice

Combine axe automation, component tests, semantic code review, keyboard exploration, screen reader workflows, zoom and reflow checks, contrast review, and user feedback. Map coverage to product risk and WCAG criteria.

Use the Cypress tutorial for beginners, apply the accessibility testing checklist, and rehearse decisions with WCAG testing interview questions.

Scale by risk, not by accumulating cases. Map critical capabilities to the cheapest reliable test layer, reserve browser workflows for integration confidence, and remove checks that no longer influence decisions. Track duration, failure category, quarantine age, and time to diagnosis. These operational measures reveal suite health more honestly than a raw test count.

For this part of accessibility testing with Cypress, define a representative success path, a meaningful rejection path, and a boundary condition. State the precondition, action, observable result, and cleanup for each. Use unique data when workers can overlap. On failure, retain the expected state plus the browser, network, console, or event evidence that can separate a product defect from a test defect.

Consider the section complete only when the check fails for the intended regression, passes for correct behavior, survives repeated and reordered execution, and produces a message another engineer can act on. Review that standard when the interface, environment, ownership, or delivery pipeline changes.

Interview Questions and Answers

These concise answers are starting points. In a real interview, add one example from a suite you built or diagnosed.

Q: Why use axe with Cypress?

Start by defining the observable behavior and its risk. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Q: Does a clean axe scan prove WCAG conformance?

The key distinction is between framework mechanics and product state. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Q: Why call injectAxe after visiting?

A strong implementation favors deterministic setup and evidence. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Q: When should you scope checkA11y?

Treat this as a design decision, not a memorized command. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Q: How do you test dialog focus?

Start by defining the observable behavior and its risk. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Q: Should teams disable failing rules?

The key distinction is between framework mechanics and product state. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Q: What belongs in CI?

A strong implementation favors deterministic setup and evidence. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Q: How do you triage repeated violations?

Treat this as a design decision, not a memorized command. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Common Mistakes

  • Automating an unclear requirement and treating execution as validation.
  • Using fixed delays or broad retries to conceal an unknown state.
  • Sharing mutable users or records across parallel workers.
  • Selecting elements through incidental layout instead of a stable contract.
  • Logging secrets, personal data, or authentication material in artifacts.
  • Ignoring skipped, quarantined, or intermittently passing tests.
  • Measuring test count instead of risk coverage and actionable feedback.

Correct these problems through small code reviews, failure classification, owned debt, and deletion of low-value checks. A test earns its maintenance cost when it detects a meaningful regression and tells the team what happened.

Conclusion

accessibility testing with Cypress is most valuable when the implementation connects supported tooling to product risk, isolated data, observable assertions, and useful diagnostics. Start with one critical workflow, prove that it fails and passes for the right reasons, then expand by risk.

Keep the suite understandable to the next engineer. Review its coverage, runtime, and failure patterns regularly, and pair automation with targeted human investigation. Put the first useful check into the normal pull request workflow, assign an owner, and inspect its first several failures. Early operational feedback will show whether the design produces a dependable decision signal or merely more test output.

Interview Questions and Answers

Why use axe with Cypress?

Start by defining the observable behavior and its risk. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Does a clean axe scan prove WCAG conformance?

The key distinction is between framework mechanics and product state. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Why call `injectAxe` after visiting?

A strong implementation favors deterministic setup and evidence. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

When should you scope `checkA11y`?

Treat this as a design decision, not a memorized command. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

How do you test dialog focus?

Start by defining the observable behavior and its risk. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Should teams disable failing rules?

The key distinction is between framework mechanics and product state. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

What belongs in CI?

A strong implementation favors deterministic setup and evidence. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

How do you triage repeated violations?

Treat this as a design decision, not a memorized command. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

How would you review accessibility testing with Cypress practice 9?

Start by defining the observable behavior and its risk. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

How would you review accessibility testing with Cypress practice 10?

The key distinction is between framework mechanics and product state. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

How would you review accessibility testing with Cypress practice 11?

A strong implementation favors deterministic setup and evidence. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

How would you review accessibility testing with Cypress practice 12?

Treat this as a design decision, not a memorized command. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Frequently Asked Questions

Why use axe with Cypress?

Start by defining the observable behavior and its risk. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Does a clean axe scan prove WCAG conformance?

The key distinction is between framework mechanics and product state. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Why call `injectAxe` after visiting?

A strong implementation favors deterministic setup and evidence. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

When should you scope `checkA11y`?

Treat this as a design decision, not a memorized command. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

How do you test dialog focus?

Start by defining the observable behavior and its risk. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Should teams disable failing rules?

The key distinction is between framework mechanics and product state. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

What belongs in CI?

A strong implementation favors deterministic setup and evidence. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

How do you triage repeated violations?

Treat this as a design decision, not a memorized command. In accessibility testing with Cypress, I would use the smallest supported API that expresses the condition, keep data isolated, and assert a user-visible or externally verifiable outcome. I would also capture diagnostics and explain the tradeoff, because a correct answer includes maintainability and CI behavior, not only syntax.

Related Guides