Skip to content

Instantly share code, notes, and snippets.

@nfreear
Last active March 7, 2018 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfreear/cece86bf6d5d4d531bf0646417a868fb to your computer and use it in GitHub Desktop.
Save nfreear/cece86bf6d5d4d531bf0646417a868fb to your computer and use it in GitHub Desktop.
Dynamically generate a 'pa11y-ci' JSON configuration object, using an environment variable | https://github.com/pa11y/pa11y-ci
/*!
Pa11y-ci Configuration.
Dynamically generate a '.pa11yci' JSON config object, using an environment variable.
© Nick Freear, 07-March-2018.
https://gist.github.com/nfreear/cece86bf6d5d4d531bf0646417a868fb
https://github.com/pa11y/pa11y-ci/issues/48
USAGE:
export TEST_SRV=https://example.edu/moodle # Or, set via Travis-CI UI.
pa11y-ci -c .pa11yci.conf.js
*/
var config = {
defaults: {
screenCapture: './_pa11y-screen-capture.png',
standard: 'WCAG2AA',
ignore: [ 'notice' ],
timeout: 5000,
wait: 1500
},
urls: [
'${TEST_SRV}/page1.html?_ua=pa11y',
'${TEST_SRV}/page2.html?_ua=pa11y',
'${TEST_SRV}/page3.html?_ua=pa11y'
]
};
function myPa11yCiConfiguration (urls, defaults) {
console.error('Env:', process.env.TEST_SRV);
for (var idx = 0; idx < urls.length; idx++) {
urls[ idx ] = urls[ idx ].replace('${TEST_SRV}', process.env.TEST_SRV);
}
return {
defaults: defaults,
urls: urls
}
};
// Important ~ call the function, don't just return a reference to it!
module.exports = myPa11yCiConfiguration (config.urls, config.defaults);
// End config.
@nfreear
Copy link
Author

nfreear commented Mar 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment