Last active
March 7, 2018 16:58
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
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. |
Author
nfreear
commented
Mar 7, 2018
- Relates to bug/ issue ~~ pa11y/pa11y-ci#48
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment