### Start Testcase Server Locally Source: https://github.com/ibma/equal-access/blob/main-4.x/karma-accessibility-checker/README.md In the karma-accessibility-checker directory, install dependencies and start the testcase server. ```bash npm install node RuleServerLocal ``` -------------------------------- ### Start Rule Server Locally Source: https://github.com/ibma/equal-access/blob/main-4.x/karma-accessibility-checker/README.md Navigate to the rule-server directory, install dependencies, and start the server to run tests locally. ```bash cd ../rule-server npm install npm start ``` -------------------------------- ### Quick Start: Initialize Checker and Run Check Source: https://github.com/ibma/equal-access/blob/main-4.x/accessibility-checker-engine/README-NPM.md Initialize the Checker and perform an accessibility check on the document using the IBM_Accessibility ruleset. This example uses Promises. ```javascript const checker = new ace.Checker(); const report = await checker.check(document, ["IBM_Accessibility"]); ``` -------------------------------- ### Initial Feature Flag Setup Source: https://github.com/ibma/equal-access/blob/main-4.x/common/module/test/report/report1_expected.html Initializes the feature flag system by creating a manager instance and adding predefined flags. This setup ensures that all flags are available and configured at the start of the application. ```javascript var g = [{ name: "enable-css-custom-properties", description: "Describe what the flag does", enabled: v.enableCssCustomProperties }, { name: "enable-use-controlled-state-with-value", description: "Enable components to be created in either a controlled or uncontrolled mode\n", enabled: v.enableUseControlledStateWithValue }, { name: "enable-css-grid", description: "Enable CSS Grid Layout in the Grid and Column React components\n", enabled: v.enableCssGrid }, { name: "enable-v11-release", description: "Enable the features and functionality for the v11 Release\n", enabled: v.enableV11Release }]; for (var T = M(), C = 0; C < g.length; C++) { var H = g[C]; T.add(H.name, H.enabled) } ``` -------------------------------- ### Install Dependencies with npm Source: https://github.com/ibma/equal-access/blob/main-4.x/accessibility-checker/boilerplates/jest/README.md Run this command to install all project dependencies. ```bash npm install ``` -------------------------------- ### Start Karma Tests Source: https://github.com/ibma/equal-access/blob/main-4.x/karma-accessibility-checker/README.md Run the karma start command to initiate the testing process. ```bash karma start ``` -------------------------------- ### Install Karma Plugin Source: https://github.com/ibma/equal-access/blob/main-4.x/karma-accessibility-checker/README.md Run the installPlugin script to install the packaged files into the local node_modules. ```bash npm run installPlugin ``` -------------------------------- ### Install accessibility-checker-engine (npm) Source: https://github.com/ibma/equal-access/blob/main-4.x/accessibility-checker-engine/README-NPM.md Install the engine as a development dependency in a Node.js environment. ```bash $ npm install --save-dev accessibility-checker-engine ``` -------------------------------- ### Install vitest-accessibility-checker Source: https://github.com/ibma/equal-access/blob/main-4.x/vitest-accessibility-checker/src/README.md Install the accessibility checker package as a development dependency. ```bash npm install --save-dev vitest-accessibility-checker ``` -------------------------------- ### Install accessibility-checker globally Source: https://github.com/ibma/equal-access/blob/main-4.x/accessibility-checker/src/README.md Install the accessibility-checker command-line tool globally using npm for system-wide access. ```bash $ npm install -g accessibility-checker ``` -------------------------------- ### Run Development Server Source: https://github.com/ibma/equal-access/blob/main-4.x/vitest-accessibility-checker/boilerplates/vitest/README.md Start the development server for the React application. ```bash npm run dev ``` -------------------------------- ### Setup Custom Matcher for Accessibility Source: https://github.com/ibma/equal-access/blob/main-4.x/vitest-accessibility-checker/src/README.md Extend Vitest's expect with the toBeAccessible matcher by creating a setup file and referencing it in your vitest config. This provides a cleaner testing syntax. ```javascript // setupMatchers.js import { expect } from 'vitest' import { toBeAccessible } from 'vitest-accessibility-checker/matchers' expect.extend({ toBeAccessible }) ``` ```javascript export default defineConfig({ test: { setupFiles: ['./setupMatchers.js'], browser: { enabled: true, name: 'chromium', provider: 'playwright' } } }) ``` -------------------------------- ### Install Playwright Browsers Source: https://github.com/ibma/equal-access/blob/main-4.x/vitest-accessibility-checker/README.md Installs the necessary Playwright browsers to resolve 'Executable doesn't exist' errors. ```bash npx playwright install chromium ``` -------------------------------- ### Install cypress-accessibility-checker Source: https://github.com/ibma/equal-access/blob/main-4.x/cypress-accessibility-checker/README.md Install the cypress-accessibility-checker package as a development dependency using npm. ```bash npm install cypress-accessibility-checker --save-dev ``` -------------------------------- ### HTML Document Write Example Source: https://github.com/ibma/equal-access/blob/main-4.x/accessibility-checker-engine/test/v2/checker/accessibility/rules/RPT_Media_ImgColorUsage_ruleunit/Color-usage.html Demonstrates the use of `document.write` to insert content into an HTML document. This is a basic example of dynamic content generation. ```html document.write("Hello World!") ``` -------------------------------- ### Build All Tools Source: https://github.com/ibma/equal-access/blob/main-4.x/README.md Build all tools and components within the repository. Ensure you have run 'npm install' first. ```bash npm run build ``` -------------------------------- ### Run All Tests Source: https://github.com/ibma/equal-access/blob/main-4.x/karma-accessibility-checker/README.md Execute the npm test command to build, install the plugin, and run Karma tests. ```bash npm test ``` -------------------------------- ### Example Rule Object Implementation Source: https://github.com/ibma/equal-access/blob/main-4.x/accessibility-checker-engine/README-RULES.md This example demonstrates the structure of a rule object, including its ID, context, refactoring, help messages, ruleset mappings, and the run function that executes the rule logic. It shows how to return a manual rule result. ```javascript { id: "body_all_trigger", context: "dom:body", refactor: { "OLDID_Trigger": { "Manual_0": "manual_always" } }, help: { "en-US": { 0: `body_all_trigger.html`, "manual_always": `body_all_trigger.html` } }, messages: { "en-US": { "group": "Grouping label for the rule", "manual_always": "Check the body element for something" } }, rulesets: [{ id: [ "IBM_Accessibility", "WCAG_2_0", "WCAG_2_1"], num: "2.1.1", // num: [ "2.4.4", "x.y.z" ] also allowed level: eRulePolicy.RECOMMENDATION, toolkitLevel: eToolkitLevel.LEVEL_FOUR }], act: {}, run: (context: RuleContext, options?: {}, contextHierarchies?: RuleContextHierarchy): RuleResult | RuleResult[] => { const ruleContext = context["dom"].node as Element; const domAttrs = context["dom"].attributes; return RuleManual("manual_always"); } } ``` -------------------------------- ### Install karma-accessibility-checker with npm Source: https://github.com/ibma/equal-access/blob/main-4.x/karma-accessibility-checker/src/README.md Install the karma-accessibility-checker plugin as a development dependency using npm. ```sh npm install --save-dev karma-accessibility-checker ``` -------------------------------- ### Ordered List Example Source: https://github.com/ibma/equal-access/blob/main-4.x/accessibility-checker-engine/test/v2/checker/accessibility/rules/list_structure_proper_ruleunit/Lists-withLiAndTemplate.html Demonstrates a basic ordered list structure in HTML. ```html 1. text 1 2. text 2 3. text 3 ``` -------------------------------- ### Screen Reader Simulation Test Example Source: https://github.com/ibma/equal-access/blob/main-4.x/accessibility-checker/boilerplates/jest-puppeteer-ts/README.md This example demonstrates using the experimental `getSimulation` API to test screen reader output. It allows for regression testing of the screen reader experience. ```typescript import { getSimulation } from "accessibility-checker"; test('SR simulation has not regressed', async() => { const simulation = await getSimulation(page, 'test_name'); expect(simulation).toEqual([ { "region": "", "heading": "", "item": "[Start of document: ..."", ... }, // ... more simulation output ]); }) ``` -------------------------------- ### Example 2: Flexbox links with min-height/min-width Source: https://github.com/ibma/equal-access/blob/main-4.x/accessibility-checker-engine/test/v2/checker/accessibility/rules/target_spacing_sufficient_ruleunit/w3c_pass_example.html This example utilizes `display: flex` for the pagination menu and applies `min-height` and `min-width` directly to the anchor tags (links). This approach ensures the targets meet the minimum size requirements for WCAG 2.5.5 Target Size (AAA). ```css ol.pagination-2 { display:flex; flex-wrap: wrap; } ol.pagination-2 a{ display: block; line-height:44px; text-align: center; min-height:44px; min-width: 44px; padding: 0 0.2em; } ol.pagination-2 li { color:black; background-color:#fed; margin:0.1rem; } ``` -------------------------------- ### Run Cypress Interactive Source: https://github.com/ibma/equal-access/blob/main-4.x/cypress-accessibility-checker/boilerplates/README.md Start the HTTP server and open Cypress in interactive mode for development and debugging. ```bash npm run test-start-http # Open Cypress npm run cypress:open ``` -------------------------------- ### Unordered List Example Source: https://github.com/ibma/equal-access/blob/main-4.x/accessibility-checker-engine/test/v2/checker/accessibility/rules/list_structure_proper_ruleunit/Lists-withLiAndTemplate.html Demonstrates a basic unordered list structure in HTML. ```html Unordered List table { border: solid gray 1px; width: 100% } td, th { border-style: inset; border-width: 1px; padding: 10px; } #### An Unordered List: * text 1 * text 2 * text 3 ``` -------------------------------- ### Run Vitest Tests in Test Directory Source: https://github.com/ibma/equal-access/blob/main-4.x/vitest-accessibility-checker/README.md Navigates to the test directory, installs dependencies, and runs Vitest tests. ```bash cd test npm install npx vitest run ``` -------------------------------- ### ARIA 1.2 Combobox Pattern Example Source: https://github.com/ibma/equal-access/blob/main-4.x/accessibility-checker-engine/help-v4/en-US/combobox_haspopup_valid.html This example demonstrates the recommended ARIA 1.2 combobox pattern, including label, input with appropriate ARIA attributes, and a listbox with options. ```html