
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
@sa11y/matcher
Advanced tools
@sa11y/matcherAccessibility matcher core utilities for custom and framework-agnostic automated accessibility testing.
The @sa11y/matcher package provides programmatic APIs to check accessibility of HTML elements or the DOM, using the same underlying logic as the Sa11y Jest matcher. It is intended for use in custom test runners, integration with other frameworks, or advanced scenarios where you want direct control over accessibility checks.
yarn add -D @sa11y/matchernpm install -D @sa11y/matcherYou can use the runA11yCheck function to programmatically check the accessibility of the entire document or a specific element.
import { runA11yCheck } from '@sa11y/matcher';
(async () => {
// Check the entire document for accessibility issues
const result = await runA11yCheck(document);
if (!result.isAccessible) {
console.error('Accessibility issues found:', result.a11yError);
} else {
console.log('No accessibility issues found!');
}
// Check a specific element
const elem = document.getElementById('foo');
const elemResult = await runA11yCheck(elem);
if (!elemResult.isAccessible) {
// Handle accessibility errors
}
})();
You can also pass a custom ruleset from @sa11y/preset-rules:
import { runA11yCheck } from '@sa11y/matcher';
import { extended } from '@sa11y/preset-rules';
await runA11yCheck(document, extended);
The runAutomaticCheck API can be used to automatically check each child element in the DOM body for accessibility issues, similar to the automatic checks in the Jest integration.
import { runAutomaticCheck, defaultAutoCheckOpts, defaultRenderedDOMSaveOpts } from '@sa11y/matcher';
await runAutomaticCheck(
{
cleanupAfterEach: true, // Optionally clean up the DOM after checking
runAfterEach: true, // Run after each test (if used in a test runner)
},
{
renderedDOMDumpDirPath: './a11y-dumps',
generateRenderedDOMFileSaveLocation: (testFilePath, testName) => ({
fileName: `${testName}.html`,
fileUrl: `/a11y-dumps/${testName}.html`,
}),
}
);
autoCheckOpts (AutoCheckOpts): Options for automatic accessibility checks (see below)renderedDOMSaveOpts (RenderedDOMSaveOpts): Options for saving the rendered DOM during automatic checks. Allows customizing how and where the DOM is saved for debugging or reporting purposes.AutoCheckOpts:
runAfterEach: Run after each test (for integration with test runners)cleanupAfterEach: Clean up the DOM after checkingconsolidateResults: Deduplicate resultsfilesFilter: Array of file path substrings to skip automatic checks forrunDOMMutationObserver: Enable DOM mutation observer modeenableIncompleteResults: Include incomplete resultsRenderedDOMSaveOpts:
renderedDOMDumpDirPath: Directory path where the rendered DOM HTML files will be saved.generateRenderedDOMFileSaveLocation: Function to generate the file name and URL for saving the rendered DOM, given the test file path and test name.You can use other exports for custom integrations, such as mutationObserverCallback, observerOptions, RenderedDOMSaveOpts, defaultRenderedDOMSaveOpts, and more.
Accessibility errors are grouped and reported by rule violation for easier debugging.
FAQs
Accessibility testing matcher defination
The npm package @sa11y/matcher receives a total of 3,408 weekly downloads. As such, @sa11y/matcher popularity was classified as popular.
We found that @sa11y/matcher demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.