{"id":10477,"library":"accessibility-developer-tools","title":"Accessibility Developer Tools (ADT)","description":"The Accessibility Developer Tools (ADT) library provides a suite of accessibility-related testing and utility code primarily for web browsers. Its core functionality includes an accessibility audit API, offering a collection of rules to check for common accessibility problems within an HTML page. Beyond auditing, it offers utilities such as contrast ratio calculation, ARIA attribute validation, and accessible name computation following WAI-ARIA specifications. The current stable version is 2.12.0, with a release cadence that appears somewhat irregular, often driven by bug fixes, performance enhancements, and new audit rules. Key differentiators include its focus on practical, rule-based audits for web content and its integration capabilities with testing frameworks like Selenium and headless browsers like PhantomJS. It's often used in CI/CD pipelines to automate accessibility checks.","status":"active","version":"2.12.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/GoogleChrome/accessibility-developer-tools","tags":["javascript","accessibility","testing","WCAG"],"install":[{"cmd":"npm install accessibility-developer-tools","lang":"bash","label":"npm"},{"cmd":"yarn add accessibility-developer-tools","lang":"bash","label":"yarn"},{"cmd":"pnpm add accessibility-developer-tools","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for building the project and running command-line tools.","package":"node","optional":false},{"reason":"Used for building the project via `npm install -g grunt-cli`.","package":"grunt-cli","optional":false},{"reason":"Required for the command-line audit runner tool.","package":"phantomjs","optional":true},{"reason":"Required for Closure Compiler, which is used in the build process.","package":"JDK","optional":false}],"imports":[{"note":"The library primarily exposes a global `axs` object when included in a browser. For Node.js environments, starting from v2.11.0, it can be `require`d, which typically assigns the `axs` object as the module's default export. Named imports are not commonly supported as `axs` is the primary namespace.","wrong":"import { axs } from 'accessibility-developer-tools';","symbol":"axs","correct":"import 'accessibility-developer-tools'; // Exposes global 'axs'\n// Or for CJS:\nconst axs = require('accessibility-developer-tools');"},{"note":"Access to audit functionality is via methods on the global `axs.Audit` object. Direct imports for `Audit` are not standard.","wrong":"import { Audit } from 'accessibility-developer-tools';\nAudit.run();","symbol":"axs.Audit.run","correct":"// After importing or including the library:\naxs.Audit.run();"},{"note":"Constants like `AuditResult` are nested under `axs.constants` and accessed directly after the library is loaded, not via separate named imports.","wrong":"import { AuditResult } from 'accessibility-developer-tools/constants';","symbol":"axs.constants.AuditResult","correct":"// After importing or including the library:\nconst resultType = axs.constants.AuditResult.PASS;"}],"quickstart":{"code":"import puppeteer from 'puppeteer';\n\nasync function runAccessibilityAudit(url) {\n  const browser = await puppeteer.launch();\n  const page = await browser.newPage();\n\n  await page.goto(url, { waitUntil: 'networkidle0' });\n\n  // Inject accessibility-developer-tools library\n  // This assumes the library is installed and available in node_modules\n  // or fetched from a CDN directly.\n  // For simplicity, we'll use a direct CDN path here for the browser-global version.\n  await page.addScriptTag({\n    url: 'https://raw.githubusercontent.com/GoogleChrome/accessibility-developer-tools/stable/dist/js/axs_testing.js'\n  });\n\n  // Run the audit and get results\n  const results = await page.evaluate(() => {\n    if (typeof axs === 'undefined' || !axs.Audit || !axs.Audit.run) {\n      return { error: 'accessibility-developer-tools not loaded or initialized.' };\n    }\n    const auditResults = axs.Audit.run();\n    return auditResults.map(result => ({\n      ruleName: result.rule.name,\n      result: result.result,\n      elements: result.elements ? result.elements.map(el => el.outerHTML) : []\n    }));\n  });\n\n  console.log(`Accessibility audit for ${url}:`);\n  results.forEach(item => {\n    console.log(`  Rule: ${item.ruleName} - Result: ${item.result}`);\n    if (item.elements && item.elements.length > 0) {\n      console.log('    Failing elements:', item.elements.slice(0, 3).join(' ')); // Log first 3 elements\n    }\n  });\n\n  await browser.close();\n}\n\n// Example usage: You'd typically run this against a local or staging URL\nrunAccessibilityAudit('https://www.google.com');\n","lang":"typescript","description":"This quickstart demonstrates how to use `accessibility-developer-tools` within a Node.js environment using Puppeteer to audit a web page. It injects the library into a headless browser, runs a full accessibility audit, and logs the results including failing elements."},"warnings":[{"fix":"Update calls to `axs.AuditRule.run()` to pass an options object as its single argument. Refer to the method documentation for the specific structure of the options object.","message":"The `axs.AuditRule.run()` method signature changed in v0.0.4. It now accepts an options object instead of previous arguments.","severity":"breaking","affected_versions":"<=0.0.4"},{"fix":"Ensure a recent version of JDK is installed and configured in your system's PATH. If encountering build errors related to Java or Closure Compiler, verify JDK installation.","message":"Building the project (e.g., from source) requires a Java Development Kit (JDK) to run Closure Compiler, which is used in the build process.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"For Node.js projects, upgrade to v2.11.0 or newer to ensure reliable CommonJS `require` support. If using older versions, consider loading the script directly into a JSDOM or similar browser-like environment.","message":"Prior to v2.11.0, properly `require`ing the accessibility developer tools in Node.js environments was problematic or not officially supported, primarily designed for browser global usage.","severity":"gotcha","affected_versions":"<2.11.0"},{"fix":"For fine-grained control over audit behavior, upgrade to v2.9.0 or later and utilize the object-based configuration options as described in the documentation for `axs.Audit` initialization.","message":"The audit configuration options were enhanced in v2.9.0 to support specifying options through an object when initializing audits.","severity":"gotcha","affected_versions":"<2.9.0"},{"fix":"When using with frameworks that employ Shadow DOM, ensure the auditing tool can properly traverse shadow roots. The library's ability to descend into iframes (v2.8.0) is a positive sign, but Shadow DOM behavior might differ. Manual element selection or additional context might be necessary for elements within closed shadow roots.","message":"Direct DOM manipulation and global scope reliance in accessibility tools can be less robust in modern component-based frameworks. While effective, integrating with Shadow DOM or isolated web components may require specific patterns or workarounds.","severity":"deprecated","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure the `axs_testing.js` script is included in your HTML page before any calls to `axs`, or if in Node.js, ensure `require('accessibility-developer-tools')` is executed and assigns `axs` to a global or local variable.","cause":"The `accessibility-developer-tools` library was not loaded or initialized correctly in the execution environment (e.g., browser or Node.js with JSDOM).","error":"ReferenceError: axs is not defined"},{"fix":"Verify that a compatible JDK version is installed and accessible via your system's PATH variable. Check the specific error message from Closure Compiler for more details on the cause, which might indicate a bug in the source code being compiled.","cause":"The Closure Compiler, used during the build process, encountered an error. This is often due to an improperly configured Java Development Kit (JDK) or issues within the compiler itself.","error":"Error: Command failed: java -jar ... closure-compiler.jar"},{"fix":"This typically means the library loaded partially or an incorrect version. Ensure you are loading `axs_testing.js` (or the equivalent module export) and that it completes execution without errors. This can happen if dependencies for the library itself fail to load.","cause":"The `axs.Audit` object is undefined, meaning the core audit functionality was not exposed or initialized when the `axs` global object was created.","error":"Cannot read property 'run' of undefined (reading 'Audit')"}],"ecosystem":"npm"}