pa11y / pa11y-ci

Pa11y CI is a CI-centric accessibility test runner, built using Pa11y
https://pa11y.org
GNU Lesser General Public License v3.0
520 stars 63 forks source link

Request for feedback - badges, '--init' flag, environment variables [enhancement ideas] #48

Closed nfreear closed 2 years ago

nfreear commented 6 years ago

Hi,

I'm loving and using pa11y-ci. Thank you to all contributors, and the pa11y team!

I've got some suggestions and ideas, that I'd like some feedback on.

Then I may be able to implement them, and create a pull request ...

  1. Suggest badges (via https://shields.io) in the documentation for use in READMEs to promote pa11y-ci, for example, Accessibility testing

    [![Accessibility testing](https://img.shields.io/badge/accessibility-pa11y--ci-blue.svg)](https://github.com/pa11y/pa11y-ci)
  2. An --init or --defaults flag. pa11y-ci --init would interactively create a .pa11yci.json file, rather like npm init pa11y-ci --defaults > .pa11yci.json would dump a default configuration to file. (Example, https://gist.github.com/nfreear/785dce9698bcd9656b6d3fa5ffee9b47)

  3. Support for environment variables in .pa11yci.json files. Why? Useful when running tests on multiple URLs on a visible, but un-advertised test-server,

    Example,

    export TEST_SRV=https://test.example.org  # Or, set via Travis-CI user-interface.
    
    pa11y-ci -C .pa11yci.json

    Then,

    {
      "defaults": { },
      "urls": [
        "${TEST_SRV}/page1.html",
        "${TEST_SRV}/page2.html",
        "${TEST_SRV}/page3.html",
      ]
    }

Yours,

Nick

(FYI, I've recently blogged about my use of pa11y-ci.)

"Automated accessibility testing - via 'pa11y-ci'"

nfreear commented 6 years ago

Hi,

To follow-up, I've answered one of my enhancement ideas ...

Point 3, Support for environment variables -- pa11y-ci accepts configuration files as JSON or Javascript -- in either case they are required by pa11y-ci. So, the following works.

.pa11yci.conf.js on Gist:

/*!
  Pa11y-ci Configuration.
  Dynamically generate a '.pa11yci' JSON config object, using an environment variable.
*/

var defaults = {
  standard: 'WCAG2AA',
  timeout: 5000
  // More ...
};

var urls = [
  '${TEST_SRV}/page1.html?_ua=pa11y',
  '${TEST_SRV}/page2.html?_ua=pa11y'
];

function myPa11yCiConfiguration () {

  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 return a reference to it!
module.exports = myPa11yCiConfiguration();

Then call with:

export TEST_SRV=https://test.example.org  # Or, set via Travis-CI user-interface.

pa11y-ci -c .pa11yci.conf.js

Yours,

Nick

rowanmanning commented 6 years ago

Hi @nfreear, sorry for the wait on a reply for this. I think as these are separate issues it'd be good to have different GitHub issues opened for them :)

I'll also get your blog post added to the site when I get a spare moment, thanks for writing it!

josebolos commented 2 years ago

Closing as per @rowanmanning's comment above.