Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@axe-core/react

Package Overview
Dependencies
Maintainers
4
Versions
456
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.9.2-bf76a3c.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
71K
decreased by-57.36%
Maintainers
4
Weekly downloads
 
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

FAQs

Package last updated on 02 Aug 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc