New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@axe-core/react

Package Overview
Dependencies
Maintainers
4
Versions
460
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@axe-core/react

Dynamic accessibility analysis for React using axe-core

4.10.1-aaaa34e.0
Source
npm
Version published
Maintainers
4
Created

What is @axe-core/react?

@axe-core/react is a library that integrates the axe-core accessibility testing engine with React applications. It helps developers identify and fix accessibility issues in their React components during development.

What are @axe-core/react's main functionalities?

Basic Accessibility Testing

This code demonstrates how to use @axe-core/react with Jest and Testing Library to perform basic accessibility testing on a React component. It checks for accessibility violations in the rendered output of the App component.

import React from 'react';
import ReactDOM from 'react-dom';
import { axe, toHaveNoViolations } from 'jest-axe';
import { render } from '@testing-library/react';
import App from './App';

expect.extend(toHaveNoViolations);

test('should not have any accessibility violations', async () => {
  const { container } = render(<App />);
  const results = await axe(container);
  expect(results).toHaveNoViolations();
});

Automated Accessibility Testing in Development

This code snippet shows how to integrate @axe-core/react for automated accessibility testing during development. It sets up axe to run accessibility checks on the React component tree and logs any violations to the console.

import React from 'react';
import ReactDOM from 'react-dom';
import { axe, toHaveNoViolations } from 'jest-axe';
import { render } from '@testing-library/react';
import App from './App';

if (process.env.NODE_ENV !== 'production') {
  const { axe } = require('@axe-core/react');
  axe(React, ReactDOM, 1000);
}

ReactDOM.render(<App />, document.getElementById('root'));

Other packages similar to @axe-core/react

Keywords

accessibility

FAQs

Package last updated on 28 Oct 2024

Did you know?

Socket

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.

Install

Related posts