liip / TheA11yMachine

The A11y Machine is an automated accessibility testing tool which crawls and tests pages of any web application to produce detailed reports.
https://www.liip.ch/
621 stars 66 forks source link

Pa11y reporters other than "html" fail to load #103

Open ralf57 opened 7 years ago

ralf57 commented 7 years ago

Trying to have generate a report in a different format than "html", for example with

./node_modules/.bin/a11ym http://creakingshelf.net -r json

fails, with the following error

Error: Cannot find module '../node_modules/pa11y/reporter/json'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at tester (/vagrant/node_modules/the-a11y-machine/lib/tester.js:59:24)
    at Object.start (/vagrant/node_modules/the-a11y-machine/lib/a11ym.js:203:23)
    at Object.<anonymous> (/vagrant/node_modules/the-a11y-machine/a11ym:119:21)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)

Setting the path at https://github.com/liip/TheA11yMachine/blob/master/lib/tester.js#L59 to

reporter = require('../../../node_modules/pa11y/reporter/' + options.report);

fixes it.

Hywan commented 7 years ago

Hey,

It depends whether you are using a11ym directly, or as a dependency of a project. You should not use a fix path. My recommendation would be to: Find the node_modules directly by recurring the parent directories, and then, relatively to this path, look for the reporter file.

ralf57 commented 7 years ago

@Hywan thanks for your input. Submitted https://github.com/liip/TheA11yMachine/pull/104