Closed mudit94 closed 11 months ago
Hi @mudit94,
Pa11y CI will actually accept either a JSON or JavaScript formatted configuration file. By default (i.e. if the --config
CLI argument is not specified), it will try .pa11yci
, then .pa11yci.js
, then .pa11yci.json
(per the code here if that's helpful).
So, the easiest route is to declare variables with your credentials, then use a JavaScript formatted config file to pull them, something like (assuming the AUTH_TOKEN
environment variable has an auth token):
.pa11yci.js
:
module.exports = {
{
defaults: {
headers: {
'auth-token': process.env.AUTH_TOKEN
}
},
urls: [...]
}
There are other tricks for variable substitution (e.g. something like sed
in Linux), but that's nearly as clean.
I want to use the variable in actions to be able to perform login operation. Do you have a sample code?
@mudit94 How specifically are you trying to login? Is it with some kind of access token in the headers
as shown above, using actions
to fill out form fields, or something else?
Thanks for your help here @aarongoldenthal. I've also added #197 to the list for release 3.1. @mudit94, I'll close this now as it's been a while, but please reopen if you'd like to continue the conversation.
Hi Team, I am looking for a way to be able to use environment variables in pa11yci file so that credentials need not be hardcoded