@afixt/test-utils
v1.1.7
Published
Various utilities for accessibility testing
Readme
AFixt Test Utilities
A collection of JavaScript utility functions for accessibility testing.
Installation
npm install @afixt/test-utilsUsage
CommonJS (Node.js)
const { isDataTable, hasAccessibleName, getAriaAttributesByElement } = require('@afixt/test-utils');
// Check if a table is a data table
const table = document.querySelector('table');
const isData = isDataTable(table);
// Check if an element has an accessible name
const button = document.querySelector('button');
const hasName = hasAccessibleName(button);
// Get all ARIA attributes for an element
const element = document.querySelector('[role="tab"]');
const ariaAttributes = getAriaAttributesByElement(element);ES Modules
import { isDataTable, hasAccessibleName, getAriaAttributesByElement } from '@afixt/test-utils';
// Check if a table is a data table
const table = document.querySelector('table');
const isData = isDataTable(table);
// Check if an element has an accessible name
const button = document.querySelector('button');
const hasName = hasAccessibleName(button);
// Get all ARIA attributes for an element
const element = document.querySelector('[role="tab"]');
const ariaAttributes = getAriaAttributesByElement(element);Available Utilities
This library provides utilities for:
- DOM traversal and manipulation
- Accessibility name and role computation
- ARIA attribute validation
- Table analysis
- Focus management
- Visibility detection
- Element positioning
- String manipulation
- Contrast testing
- Language detection
- And more
See the API documentation for a complete list of available functions.
Development
Building the Project
npm installRunning Tests
npm test # Run all tests
npm run test:watch # Run tests in watch mode
npm run test:coverage # Run tests with coverage
npm run test:single # Run a single testGenerating Documentation
npm run docs # Generate documentationLicense
UNLICENSED - Copyright AFixt
