QAstro.js is a modular library for automatic accessibility and security linting of web pages. Easily extensible with new rules.
- π Auto-run when the page loads
- π§ͺ Modular rules (checkTitle, checkImageAlt, checkFormLabel, etc)
- π Reports in the browser console
- π§© Easily extensible with your own rules
qastro/
βββ src/
β βββ rules/
β β βββ checkTitle.js
β β βββ checkImageAlt.js
β β βββ checkFormLabel.js
β βββ index.js
βββ dist/
β βββ qastro.min.js
βββ rollup.config.js
βββ package.json
βββ README.md
- Install dependencies:
npm install
- Build:
npm run build
Include dist/qastro.min.js in your web page. Reports will automatically appear in the browser console.
Add a new rule file in src/rules/ and import it in src/index.js.
QAstro.js can be integrated into your CI/CD pipeline or automated test environment. You can run QAstro.js in a headless browser or Node.js environment (e.g., with jsdom, Puppeteer, or Playwright) to lint your pages automatically and fail the build if issues are found.
Install jsdom:
npm install jsdom
Example script:
import { JSDOM } from 'jsdom'; import runQAstro from './src/index.js'; const dom = new JSDOM('<!doctype html><html><head></head><body></body></html>', { url: 'http://localhost' }); global.document = dom.window.document; global.window = dom.window; let issues = []; runQAstro({ report: (result) => issues.push(result) }); if (issues.length > 0) { console.error('QAstro found issues:', issues); process.exit(1); // fail CI }
You can adapt this approach for Playwright, Puppeteer, or other test runners to automate accessibility and security linting as part of your build process.