Change record status: 
Project: 
Introduced in branch: 
12.1.x
Introduced in version: 
12.1.0
Description: 

PHPUnit Functional JavaScript tests can use \Drupal\Tests\AxeCoreTestTrait to check the current page for accessibility violations with axe-core. In a test extending WebDriverTestBase, add the trait and call $this->executeAxe(); after loading and preparing the page. Checks run only when explicitly requested; adding the trait does not scan every page automatically.

The optional $options argument accepts axe.run() options, such as rules to run or disable. Reported violations fail the test and identify the affected rules and elements. Errors thrown by axe also fail the test.

For page-based test cases, extend \Drupal\FunctionalJavascriptTests\AccessibilityTestBase and implement its static provider() method. Each case supplies a path and can optionally request an administrator login, pass axe options, or name a setup method to run after navigation and before the scan.

Run yarn install in the core directory before running these tests locally so that the axe-core JavaScript library is available. Core's functional JavaScript CI job installs this dependency. Core's existing Nightwatch accessibility tests move to PHPUnit; this change does not remove Nightwatch itself.

Impacts: 
Module developers
Themers