{"id":21988138,"url":"https://github.com/veiko/jest-a11y","last_synced_at":"2026-05-06T05:40:25.971Z","repository":{"id":58978995,"uuid":"534856041","full_name":"veiko/jest-a11y","owner":"veiko","description":"✨ Custom Jest matchers for testing accessibility","archived":false,"fork":false,"pushed_at":"2023-01-03T14:07:28.000Z","size":3611,"stargazers_count":2,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T22:16:04.368Z","etag":null,"topics":["a11y","a11y-testing","jest","testing","testing-library"],"latest_commit_sha":null,"homepage":"https://veiko.github.io/jest-a11y/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/veiko.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-10T01:18:06.000Z","updated_at":"2024-03-28T16:15:34.000Z","dependencies_parsed_at":"2023-02-01T06:31:03.646Z","dependency_job_id":null,"html_url":"https://github.com/veiko/jest-a11y","commit_stats":null,"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veiko%2Fjest-a11y","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veiko%2Fjest-a11y/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veiko%2Fjest-a11y/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veiko%2Fjest-a11y/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/veiko","download_url":"https://codeload.github.com/veiko/jest-a11y/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245048281,"owners_count":20552483,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["a11y","a11y-testing","jest","testing","testing-library"],"created_at":"2024-11-29T19:15:56.929Z","updated_at":"2026-05-06T05:40:25.899Z","avatar_url":"https://github.com/veiko.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003ch1\u003ejest-a11y\u003c/h1\u003e\n\u003cimg\n    height=\"80\"\n    width=\"80\"\n    alt=\"shaka\"\n    src=\"https://raw.githubusercontent.com/veiko/jest-a11y/main/static/img/logo.svg\"\n  /\u003e\n\n\u003cp\u003eCustom Jest matchers for testing accessibility.\u003c/p\u003e\n\u003c/div\u003e\n\n---\n\n## The problem\n\nWhen writing web applications, the ability to easily follow accessibility guidelines is becoming essential. As developers, we need a framework to easily and quickly test compliance.\n\n## This solution\n\nThe `jest-a11y` project aims to provide a set of jest matchers that will check whether the provided DOM element has the correct ARIA roles and supports keyboard navigation.\n\n### FAQ:\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cstrong\u003e\n      Why are ARIA roles important?\n    \u003c/strong\u003e\n  \u003c/summary\u003e\n\nARIA roles provide semantic meaning to content, allowing screen readers and other tools to present and support interaction with object in a way that is consistent with user expectations of that type of object. ARIA roles can be used to describe elements that don't natively exist in HTML or exist but don't yet have full browser support.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cstrong\u003e\n      How is this different from \u003ca href=\"https://www.npmjs.com/package/jest-axe\"\u003e\u003ccode\u003ejest-axe\u003c/code\u003e\u003c/a\u003e?\n    \u003c/strong\u003e\n  \u003c/summary\u003e\n\nThe `jest-axe` plugin will parse through the provided DOM structure and check for any violations. This plugin will also attempt to validate keyboard navigation.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cstrong\u003e\n      Does this work with Enzyme or React Testing Library?\n    \u003c/strong\u003e\n  \u003c/summary\u003e\n\nYes. It works with either of those tools.\n\n\u003c/details\u003e\n\n## Table of Contents\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Known Issues](#known-issues)\n- [Inspiration](#inspiration)\n- [Other Solutions](#other-solutions)\n- [Issues](#issues)\n  - [🐛 Bugs](#-bugs)\n  - [💡 Feature Requests](#-feature-requests)\n- [LICENSE](#license)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Installation\n\nThis module is distributed via [npm](https://www.npmjs.com) which is bundled with [node](https://www.nodejs.org) and should be installed as one of your project's `dependencies`:\n\nWith `npm`:\n\n```sh\nnpm install --save-dev jest-a11y\n```\n\nWith `yarn`:\n\n```sh\nyarn add -D jest-a11y\n```\n\n## Usage\n\n```ts\n// In your own jest-setup.js (or any other name e.g. setupTests.js)\nimport 'jest-a11y'\n```\n\nFrom there, you can use the matchers in your tests.\n\n```jsx\ndescribe('MyButtonComponent', () =\u003e {\n  it('passes when element is valid', async () =\u003e {\n    render(\u003cbutton\u003eclick me\u003c/button\u003e)\n\n    expect(screen.getByRole('button')).toBeAccessibleButton()\n  })\n})\n```\n\n### With Typescript\n\nIf you're using TypeScript, make sure your setup file is a .ts and not a .js to include the necessary types.\n\nYou will also need to include your setup file in your tsconfig.json if you haven't already:\n\n```json\n  // In tsconfig.json\n  \"include\": [\n    ...\n    \"./jest-setup.ts\"\n  ],\n```\n\n\u003cdetails\u003e\n  \u003csummary\u003e\n    \u003cstrong\u003e\n      CommonJS and older versions of jest\n    \u003c/strong\u003e\n  \u003c/summary\u003e\n\nIn order to extend the matchers correctly in projects using CommonJS or older versions of jest it may be necessary to extend `expect` manually. This can be achieved with:\n\n```ts\n// In your own jest-setup.js (or any other name e.g. setupTests.js)\nimport * as matchers from 'jest-a11y/lib/matchers'\n\nexpect.extend(matchers)\n```\n\n\u003c/details\u003e\n\n## Inspiration\n\nAs I have been working on different web projects, accessibility has started to become a major concern and product requirement, but it can be cumbersome to re-write the re-test the same functionality across multiple projects. As projects also started shifting to React Testing Library instead of Enzyme, it now became possible to test DOM output and keyboard navigation in unit tests.\n\n## Other Solutions\n\nThere's [jest-axe](https://github.com/nickcolley/jest-axe) which exports a single matcher and doesn't (yet) test any user interactions.\n\n## Issues\n\n_Looking to contribute? Look for the [Good First Issue](https://github.com/veiko/jest-a11y/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) label._\n\n### 🐛 Bugs\n\nPlease file an issue for bugs, missing documentation, or unexpected behavior.\n\n- [**File a bug**](https://github.com/veiko/jest-a11y/issues/new?assignees=\u0026labels=%F0%9F%90%9B+fix\u0026template=bug_report.yml\u0026title=fix%3A+)\n- [**See existing bugs**](https://github.com/veiko/jest-a11y/labels/%F0%9F%90%9B%20fix)\n\n### 💡 Feature Requests\n\nPlease file an issue to suggest new features. Vote on feature requests by adding a 👍. This helps maintainers prioritize what to work on.\n\n[**See Feature Requests**](https://github.com/veiko/jest-a11y/labels/%E2%9C%A8%20feature)\n\n## LICENSE\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveiko%2Fjest-a11y","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fveiko%2Fjest-a11y","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveiko%2Fjest-a11y/lists"}