These examples show how to run the rulesets using a Selenium/Mocha/Chai framework:
- selenium-webdriver
- mocha
- chai
See the prerequisites.
Run the following commands:
git clone https://github.com/eBay/accessibility-ruleset-runner/
cd accessibility-ruleset-runner/examples/nodejs
Note: If you are working from a forked repository, you might use slightly different commands than those given above. Also, if you have already downloaded the code, you can skip step.
To install dependencies, run the following command from the examples/nodejs directory:
npm install
To run the Custom Ruleset, run the following command from the examples/nodejs directory:
npm run custom.ruleset.runner
The output should match the Custom Ruleset Runner Output.
To run the aXe Ruleset, run the following command from the examples/nodejs directory:
npm run aXe.ruleset.runner
The output should match the aXe Ruleset Runner Output.
The examples are setup to be run without any configuration necessary. However, users can test a different url by modifying the following line:
var url = "http://www.google.com";
In addition, sometimes users need to sign in, load urls, click buttons, etc before testing a view. Consider making the appopriate modifications necessary for your use case.
These steps show how to use the published NPM module in your project.
- Install accessibility-ruleset-runner to bring in the javascript files for the custom/axe rulesets.
npm install @ebay/accessibility-ruleset-runner --save-dev
Note: You may modify the version by editing the package.json file.
- Edit the custom.ruleset.runner.js and axe.ruleset.runner.js to point to the installed custom.ruleset.X.X.X.js and axe.ruleset.X.X.X.js javascript files (replace X's appropriately)
var customRuleset = fs.readFileSync('./node_modules/accessibility-ruleset-runner/rulesets/custom.ruleset.X.X.X.js','utf8');
var aXeRuleset = fs.readFileSync('./node_modules/accessibility-ruleset-runner/rulesets/aXe.ruleset.X.X.X.js','utf8');
-
Copy the custom.ruleset.runner.js and axe.ruleset.runner.js into a folder within your project
-
Configure the scripts section of the package.json to include the runner (replace src/XXX with the folder used in Step 3)
"scripts": {
...
"custom.ruleset.runner": "mocha src/XXX/custom.ruleset.runner.js",
"aXe.ruleset.runner": "mocha src/XXX/aXe.ruleset.runner.js",
},