By @_angelmm:
actions:[
'wait for path to be /select-passenger',
'screen capture second.png'
]
"a11y-check": "npm run build && start-server-and-test 'http-server ./dist --silent' 8080 'pa11y http://localhost:8080'"
"a11y-check-local-build": "npm run build && start-server-and-test 'http-server ./dist -c-1 --silent' 8080 'node pa11y/index.js 'http://localhost:8080''"
/*
Accessibility test example
- actions are the steps to execute before running the test
- hideElements: needed because the pa11y check hidden prefetch images otherwise
- log to display what's happening to the console
*/
'use strict'
const pa11y = require('pa11y')
let URL = '';
// Get url to test performance
(() => {
const argv = process.argv.slice(2)
URL = argv[0]
})()
function errorIfIssues(results) {
if (results && results.issues.length > 0) {
console.error(results)
process.exit(1)
}
}
pa11y(URL, {
actions: [
// First page
'click element .button-instructions',
// First screen game
'wait for element .button-game to be visible'
],
hideElements: "[class^='prefetch-image-wrapper']",
log: {
debug: (message) => {
if (!message.startsWith('Browser Console:')) {
console.log(message)
}
},
error: console.error,
info: console.log
}
}).then((results) => {
errorIfIssues(results)
}).catch((error) => {
throw new Error(error)
})