Skip to main content
Version: 3.0.0

Writing Custom Accessibility Tests

The AudioEye Accessibility Testing SDK allows you to write custom tests using the @audioeye/testing-sdk-core package. This package provides the core functionality used for all of our testing frameworks. If specific framework coverage is not provided, you can use this package to write your own tests.

Pre-requisites

Visit the Getting Started guide to install the SDK and set up your project.

Usage

Use the findIssues function to run your custom tests. This function can be imported from @audioeye/testing-sdk-core. The return type of this function is a Result provided by the ts-results package. The Result type is a wrapper around an Ok type of TestingSdkAllResultType and an Err type of string.

Importing the function

import { findIssues } from '@audioeye/testing-sdk-core';

findIssues type signature

import { Result } from 'ts-results';
import type { RenderResult } from '@testing-library/react';

type EvaluateRulesInputType = string | RenderResult | HTMLElement | DocumentFragment | JQuery<HTMLElement>;

type RunOptions = {
browserMode: 'virtual' | 'real';
runMode: 'external' | 'embedded';
resultsToFilter?: Set<string>;
component?: boolean;
printTestList?: boolean;
debug?: boolean;
format?: 'html' | 'json' | 'csv';
viewportDimensions?: {
width: number;
height: number;
};
mobile?: boolean;
output?: string;
stdout?: boolean;
timeout?: number;
cssSelectors?: boolean;
localWindow?: Window;
metadataToExclude?: (keyof RuleMetaOutput)[];
};

type TestingSdkAllResultType = {
ruleResults: TestingSdkRuleResultType[];
exitCode: number;
summaryResults: string;
formattedResults: string;
};

type TestingSdkRuleResultType = {
ruleCode: string;
ruleMetadata: RuleMetaOutput | undefined;
result: string;
source: string;
cssSelector?: string;
};

type RuleMetaOutput = {
code: string;
description: string;
fixAtSource: boolean;
fullName: string;
sourceFixGuidance?: string;
wcagSuccessCriteriaLevelCode: string;
wcagSuccessCriteriaName: string;
wcagSuccessCriteriaNumber: string;
};

declare const findIssues: (
input: EvaluateRulesInputType,
partialRunOptions?: Partial<RunOptions>,
) => Result<TestingSdkAllResultType, string>;

Example

import { findIssues } from '@audioeye/testing-sdk-core';

const result = findIssues(document.body);

if (!result.ok) {
throw new Error(result.val);
}

const { ruleResults, exitCode, summaryResults, formattedResults } = result.val;

// Handle the results