GithubHelp home page GithubHelp logo

pa11y / pa11y-webservice Goto Github PK

View Code? Open in Web Editor NEW
152.0 178.0 64.0 539 KB

Pa11y Webservice provides scheduled accessibility reports for multiple URLs

Home Page: https://pa11y.org

License: GNU General Public License v3.0

JavaScript 100.00%
a11y accessibility webservice mongo pa11y rest-api

pa11y-webservice's Introduction

Pa11y Webservice

NPM version Node.js version support Build status GPL-3.0 licensed

Pa11y Webservice is a Node.js service that can schedule accessibility testing for multiple URLs, using Pa11y.

Use this service if you'd like to coordinate your testing by interacting with a restful API. For other scenarios, another Pa11y tool may be more appropriate:

  • Pa11y Dashboard provides a visual interface
  • Pa11y CI, and Pa11y itself, can be executed from the command line, which is likely to be more useful for accessibility testing as part of a CI/CD workflow

Requirements

  • Node.js: Each major version of Pa11y Webservice is designed to support a set of stable/LTS versions of Node.js. Pa11y Webservice 4 requires a stable (even-numbered) version of Node.js of 12 or above.
  • MongoDB: The service stores test results in a MongoDB database, and expects one to be available and running.

Pally Webservice 4 and Linux/Ubuntu

Pa11y (and therefore this service) uses Headless Chrome to perform accessibility testing. On Linux and other Unix-like systems, Pa11y's attempt to install it as a dependency sometimes fails since additional operating system packages will be required. Your distribution's documentation should describe how to install these.

In addition, to use Pa11y Webservice 4 with a version of Ubuntu above 20.04, a path to the Chrome executable must be defined in chromeLaunchConfig, as chromeLaunchConfig.executablePath. Version 5 of Pa11y Webservice, which will use Pa11y 7 along with a more recent version of Puppeteer, will resolve this issue.

Setup

Clone this repository:

git clone https://github.com/pa11y/pa11y-webservice.git

Now install its dependencies:

cd pa11y-webservice
npm install

We're nearly ready to run the service, but first we must provide some configuration.

Configuration

The service can be configured in one of two ways: using environment variables, or using a configuration file. When both are present, the file's contents will override the environment variables. We provide some sample configuration files for reference.

Each configurable option is documented here, listed by its JSON-file property name. The environment variable equivalent for each option is identical, but upper-snake-cased.

Configuration using environment variables

Supply each option to the service's environment. For example, to supply a port inline at the time of execution, the relevant environment variable would be PORT:

PORT=8080 npm start

Configuration using a JSON file

Configuration can also be provided by a JSON file, allowing separate configurations to be maintained for multiple contexts. This method is also the only way to configure the instance of Headless Chrome that Pa11y will use.

We label each of these contexts a 'mode'. The mode is set by the NODE_ENV environment variable, and defaults to development. Pa11y Webservice will look for the mode's configuration file at config/{mode}.json. Providing NODE_ENV=production would lead to the service looking for config/production.json:

NODE_ENV=production npm start

The config directory here contains three examples. You could use one as a base to create your own configuration.

cp config/development.sample.json config/development.json
cp config/production.sample.json config/production.json
cp config/test.sample.json config/test.json

List of configuration options

database

(string) The MongoDB connection string for your database.

Env equivalent: DATABASE.

host

(string) The host to run the application on. This is normally best left as "0.0.0.0", which means the application will run on any incoming connections.

Env equivalent: HOST.

port

(number) The port to run the application on.

Env equivalent: PORT.

cron

(string) A crontab which describes when to generate reports for each task.

Env equivalent: CRON.

numWorkers

(number) The number of workers that will be running concurrently on each cron execution.

Env equivalent: NUM_WORKERS.

chromeLaunchConfig (config file only)

(object) Options to be supplied to the instance of Headless Chrome that Pa11y will create. See chromeLaunchConfig's documentation for more information.

Env equivalent: none. This option can only be defined by a file.

API documentation

Our wiki documents the interface presented by this webservice:

Client libraries

Contributing

There are many ways to contribute to Pa11y Webservice, we cover these in the contributing guide for this repo.

If you're ready to contribute some code, follow the setup guide. The project can be linted and unit tested immediately:

npm run lint           # Lint the code
npm run test:unit      # Run the unit tests

The integration tests require the service to be running in the background, since they'll be checking its behaviour.

  1. Create a configuration file for the test mode; one can be created quickly with cp config/test.sample.json config/test.json

  2. Start the service in test mode with:

    NODE_ENV=test npm start &

    The & places the service into the background. An alternative approach is to run NODE_ENV=test npm start, suspend the process with CTRL+z, and finally run bg to place it into the background.

  3. npm run test:integration   # Run the integration tests
    npm test                   # Run both the integration tests and the unit tests mentioned above

Locally testing the GitHub Actions workflow test.yml

  1. Install Docker Desktop and Nektos Act. You can install these directly, or with a software package manager. For example, with Homebrew:

    brew install --cask docker
    brew install act
  2. To check the syntax of a GitHub Actions workflow before pushing it:

    # Verify `test.yml`
    act --dryrun push
    # Verify `publish.yml`
    act --dryrun release
  3. To test the push workflow under Node.js 18 only:

    act push --matrix node-version:18

    Add --verbose for more information.

Fixtures

If you'd like to preview Pa11y Webservice or present it to someone else, we've provided some sample tasks and results, which can be embedded by running one of the following commands:

NODE_ENV=development npm run load-fixtures
NODE_ENV=test npm run load-fixtures

Support and migration

Note

We maintain a migration guide to help you migrate between major versions.

When we release a new major version we will continue to support the previous major version for 6 months. This support will be limited to fixes for critical bugs and security issues. If you're opening an issue related to this project, please mention the specific version that the issue affects.

The following table lists the major versions available and, for each previous major version, its end-of-support date, and its final minor version released.

Major version Final minor version Node.js support Support end date
4 >= 12 ✅ Current major version
3 3.2.1 8, 10 2022-05-26
2 2.3.1 4, 6 2020-01-04
1 1.11.1 0.10, 0.12, 4, 6 2016-12-05

License

Pa11y Webservice is licensed under the GNU General Public License 3.0.
Copyright © 2013-2024, Team Pa11y and contributors

pa11y-webservice's People

Contributors

alex20484096 avatar andrewmee avatar carlochess avatar danyalaytekin avatar dependabot[bot] avatar dotcode avatar dracos avatar hollsk avatar joeyciechanowicz avatar joscha avatar josebolos avatar joshski avatar jsa34 avatar jtechera avatar lc512k avatar nickcall avatar paazmaya avatar rayraegah avatar robloach avatar rowanmanning avatar rtshilston avatar sangitamane avatar sudheesh001 avatar wilco42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pa11y-webservice's Issues

Automatically remove older results

If you have a large number of URLs that are audited daily, the database can get filled up really quickly. I searched in the code base and I don't think there's a mechanism in place that removes old results? For example all results older than 30 days.

Fix npm audit issues

Currently, there are 61 security issues with the dependencies of pa11y-webservice. npm audit provides partial solutions to those. My approach is:

  • npm install hapi@^16.7.0
  • npm install joi@^14.3.0
  • npm install --save-dev [email protected]

The problem with this is that mocha freezes after tests run. They explain why in these patch notes (https://boneskull.com/mocha-v4-nears-release/#mochawontforceexit) and I could make it stop running by appending the mocha command with --exit, but that would require a pull request to https://github.com/rowanmanning/makefiles/blob/master/Makefile.node

So, can you guide me on the best way to fix this?

Cheers!

UnhandledPromiseRejectionWarning: MongoError: w has to be a non-negative number and not greater than 50

After git cloning / npm i / mongodb installation under Ubuntu 18.04 LTS and changing the webservice -> port in config.js to anything else than 3000, e. g. 5001 leads to following error:

root@didd-dev:/var/www/http/pa11y-dashboard# node index.js 

Pa11y Dashboard started
mode: undefined
uri:  http://:::5000
Server running at: http://0.0.0.0:5001

Pa11y Webservice started
mode:     undefined
uri:      http://0.0.0.0:5001
database: mongodb://localhost/pa11y-webservice
cron:     0 30 0 * * *
(node:23502) UnhandledPromiseRejectionWarning: MongoError: w has to be a non-negative number and not greater than 50
    at Function.MongoError.create (/var/www/http/pa11y-dashboard/node_modules/mongodb-core/lib/error.js:31:11)
    at /var/www/http/pa11y-dashboard/node_modules/mongodb-core/lib/connection/pool.js:497:72
    at authenticateStragglers (/var/www/http/pa11y-dashboard/node_modules/mongodb-core/lib/connection/pool.js:443:16)
    at Connection.messageHandler (/var/www/http/pa11y-dashboard/node_modules/mongodb-core/lib/connection/pool.js:477:5)
    at Socket.<anonymous> (/var/www/http/pa11y-dashboard/node_modules/mongodb-core/lib/connection/connection.js:333:22)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
(node:23502) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:23502) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:23502) UnhandledPromiseRejectionWarning: MongoError: w has to be a non-negative number and not greater than 50
    at Function.MongoError.create (/var/www/http/pa11y-dashboard/node_modules/mongodb-core/lib/error.js:31:11)
    at /var/www/http/pa11y-dashboard/node_modules/mongodb-core/lib/connection/pool.js:497:72
    at authenticateStragglers (/var/www/http/pa11y-dashboard/node_modules/mongodb-core/lib/connection/pool.js:443:16)
    at Connection.messageHandler (/var/www/http/pa11y-dashboard/node_modules/mongodb-core/lib/connection/pool.js:477:5)
    at Socket.<anonymous> (/var/www/http/pa11y-dashboard/node_modules/mongodb-core/lib/connection/connection.js:333:22)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
(node:23502) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

When leaving it at 3000 I get the following error:

root@didd-dev:/var/www/http/pa11y-dashboard# node index.js 

Pa11y Dashboard started
mode: undefined
uri:  http://:::5000
Server running at: http://0.0.0.0:3000
Error: listen EADDRINUSE: address already in use 0.0.0.0:3000
    at Server.setupListenHandle [as _listen2] (net.js:1316:16)
    at listenInCluster (net.js:1364:12)
    at doListen (net.js:1501:7)
    at processTicksAndRejections (internal/process/task_queues.js:85:21)

When checking for other applications running on port 3000 I get nothing in return:

root@didd-dev:/var/www/http/pa11y-dashboard# ps aux | grep 3000
root     23619  0.0  0.0  13136  1028 pts/0    S+   09:19   0:00 grep --color=auto 3000

pa11y behind a proxy?

Well I'm trying pa11y dashboard and webservice but my virtualmachine is set behind a proxy. I've already set my ENV shell variables http_proxy but wasn't helpful.

As far I can see, I should invoke PhantomJS using --proxy ip:port arguments. Any advice about bootstrapping pa11y-webservice with PhantomJS arguments?

Webservice 2.0

pa11y-webservice 2.0 should be along soon. #26 adds support for Node.js 0.10–6, however we've been left behind on a few dependencies.

pa11y-webservice 2.0 will include no breaking changes except that support for Node.js 0.10–0.12 will be dropped.

Sort in CosmosDB Mongo APIs mandates indexing

Expected behaviour

Pa11y dashboard should be able to integrate with Azure Cosmos DB for MongoDB

Actual behaviour

[model:task:getAll failed
Error=2, Details='Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: db9c9b1c-6eb2-43d9-8422-0df2991f8822; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: db9c9b1c-6eb2-43d9-8422-0df2991f8822; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: db9c9b1c-6eb2-43d9-8422-0df2991f8822; Reason: (Message: {"Errors":["The order by query does not have a corresponding composite index that it can be served from."]}
ActivityId: db9c9b1c-6eb2-43d9-8422-0df2991f8822, Request URI: /apps/d76a7012-7f63-444d-b353-8a54be2d58d5/services/f84105c4-7e32-44bf-9ebf-abc37440863d/partitions/771dbbb2-eae7-45cf-bc90-14f8bc3e5295/replicas/133203351083477204s/, RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Windows/10.0.17763 cosmos-netstandard-sdk/3.18.0);););

Error: Error 500
    at Request._callback (C:\Users\80992798\pa11y-dashboard\node_modules\pa11y-webservice-client-node\lib\client.js:124:16)
    at Request.self.callback (C:\Users\80992798\pa11y-dashboard\node_modules\request\request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.<anonymous> (C:\Users\80992798\pa11y-dashboard\node_modules\request\request.js:1154:10)
    at Request.emit (events.js:315:20)
    at IncomingMessage.<anonymous> (C:\Users\80992798\pa11y-dashboard\node_modules\request\request.js:1076:12)
    at Object.onceWrapper (events.js:421:28)
    at IncomingMessage.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)](url)

Steps to reproduce

Connect to cosmos DB by azure

Run beforeScript Functions in task

In order to get past a login form, beforeScript tasks are required. This works great with JS wrappers over pa11y but does not work when combined with the webservice (which is the basis for pa11y dashboard, so login with a separate screen also doesn't work through there).

I was hoping to make this possible, or maybe I'm just missing something?

Issue with Mongo Db

Hi,
I am getting following error while running the webservice:

(node:39060) UnhandledPromiseRejectionWarning: MongoError: user is not allowed to do action [listIndexes] on [pa11y-webservice-dev.results]

Remove MongoDB testing dependency

The current testing suite for pa11y-webservice requires mongodb to be available and properly set up for the tests to run.

This is usually not much of a problem when running on a CI environment as we've already done the hard work to configure all that, but it makes it much harder to make changes to the project and test things locally. It rises the barrier for contributing to the project.

There's also the risk that, if you use a production DB to run the tests (in order to avoid setting up one local mongoDB instance) all the data will be wiped in the process. This is hostile to the user and fairly unforgiving.

I think that we should rework the tests so they don't depend on a MongoDB instance to be up.

"Topology was destroyed" error after returning from sleep

Yesterday I was running pa11y-dashboard locally for debugging purposes, put the laptop to sleep with the dashboard still running, and today after I tried to use the dashboard I started getting the following errors:

  1. Topology was destroyed: When trying, for example, to edit the details of a task (http://localhost:4000/5d33aae9c193490149107fa3/edit) the page will render correctly but Topology was destroyed will appear in the logs. Any attempt to access the DB will show this error. The app is unable to connect to the DB at all, which means that is in an unsafe/invalid state.
  2. When in that state, trying to browse some of the pages (e.g. the home page) will generate an HTTP 500 error, but not all of them will.

We should probably catch these errors and make the app either re-attempt to connect to the DB, or bail out and crash, so any process management (e.g. pm2, forever, etc) can re-launch the app.

It may seem unlikely that users ever see this message but there's a chance this could happen if a running instance gets temporarily suspended (doesn't Heroku do something like this?) but, regardless, because it's good behaviour to catch these errors and try to recover or exit cleanly instead of being stuck in a permanent "HTTP 500" state.

Problems with certain ssl-configurations?

Hello,

since a few weeks my setup pa11y dashboard running version 3.0.0 is not able to test my setup pages anymore. Error message on console is:

xxx.pa11y | Starting to run one-off task @ Wed Sep 11 2019 08:38:10 GMT+0000 (UTC) xxx.pa11y | Starting task 5d78ad119c5abb0700e8107f xxx.pa11y | > PhantomJS page created xxx.pa11y | > Opening "https://shop.xxx.com/de-de/" in PhantomJS xxx.pa11y | > PhantomJS page closed xxx.pa11y | > PhantomJS browser exited xxx.pa11y | Failed to finish task 5d78ad119c5abb0700e8107f: Error opening url "https://shop.xxx.com/de-de/" : Operation canceled xxx.pa11y | Finished running one-off task @ Wed Sep 11 2019 08:38:10 GMT+0000 (UTC)

The website im testing is reachable from the host-machine. The hoster recently changed the ssl cert in use and also disabled old versions of tls.

An upgrade to the most up to date version of the dashboard didnt help:

`Starting to run one-off task @ Wed Sep 11 2019 17:20:39 GMT+0200 (GMT+02:00)
Starting task 5d78ef8642e1ed0007aeb842

Running Pa11y on URL https://shop.xxx.com/de-de
Launching Headless Chrome
Opening URL in Headless Chrome
Injecting HTML CodeSniffer
Injecting Pa11y
Running Pa11y on the page
model:task:runById failed, with id: 5d78ef8642e1ed0007aeb842
Evaluation failed: [object Object]
Failed to finish task 5d78ef8642e1ed0007aeb842`

Im not sure if this is an issue with the dashboard or the webservice. Currently pa11y is running in a self build docker-container. Running it directly on the host-machine, even with newer node versions doesnt help.

Any clue?

The tests for "WCAG2AAA" don't include some results from "WCAG2AA" tests

I'm a developer of a web accessibility testing tool that use the pa11y-webservice app.
And durring the development I found a bug in tests for "WCAG2AAA". These results don't include some errors which return tests for "WCAG2AA".

I checked this bug in Pa11y Dashboard app and got the same issue.

I made a test for four dozen sites and see the issue is repeating on all of them.
Any of these tests doesn't include any issue of the "error" type from the "AA" level.

Here's an example made in the Pa11y Dashboard app:
Test for "WCAG2AA"
Test for "WCAG2AAA"
You can see that the "Principle1.Guideline1_4.1_4_3.G18.Fail" issue (error of AA level) from the first test, doesn't appear in the second test - https://prnt.sc/10rhagd

And the same tests on our tool:
Test for "WCAG2AA"
Test for "WCAG2AAA"

[EPIC] Release Pa11y-webservice v5

These are the tasks still missing for next release of pa11y-webservice:

  • Drop support for Node v12 (which will become unsupported in late April).
  • Add support for Node v16, and potentially v18 (which will be released in April) if the MongoDB driver adds support for it.
  • The MongoDB driver has already been upgraded from v3 to v4.4.1 on the next branch but I don't think this version of the MongoDB driver supports Node 16 already.

We should probably wait until late April / early May to see if the mongodb peeps release a 4.5 or 5.0 update for their driver in the meantime and, if not, drop support for Node 12 and release v5 of webservice anyway, as adding support for new versions of Node is not a breaking change but removing support for old versions is.

Upgrade dependencies and migrate when needed

Relating to #68, would be great to have all dependencies up to date and release a new version with minimum Node.js version 8, to match pa11y.

I would be happy to work on this via PRs, but since there are some many open PRs, not sure if there is anyone willing to review and merge...

@rowanmanning possible?

Incompatible with MongoDB 3.0

There appears to be an issue when trying to use pa11y-webservice with the latest version of MongoDB (3.0). After rolling back to MongoDB v2.6, this issue cleared up and we were able to run pa11y without problems.

[user@pa11y pa11y-dashboard]# grunt start-test
Running "nodemon:test" (nodemon) task
8 Jun 20:38:05 - [nodemon] v0.7.10
8 Jun 20:38:05 - [nodemon] to restart at any time, enter `rs`
8 Jun 20:38:05 - [nodemon] watching: /user/repo/pa11y-dashboard
8 Jun 20:38:05 - [nodemon] starting `node index.js`

pa11y-dashboard started
mode: test
uri:  http://0.0.0.0:4000

pa11y-webservice started
mode: test
uri:  http://0.0.0.0:3000

/user/repo/pa11y-dashboard/node_modules/pa11y-webservice/node_modules/mongodb/lib/mongodb/connection/base.js:242
        throw message;      
              ^
TypeError: undefined is not a function
    at __executeInsertCommand (/user/repo/pa11y-dashboard/node_modules/pa11y-webservice/node_modules/mongodb/lib/mongodb/db.js:1829:12)
    at Db._executeInsertCommand (/user/repo/pa11y-dashboard/node_modules/pa11y-webservice/node_modules/mongodb/lib/mongodb/db.js:1930:5)
    at /user/repo/pa11y-dashboard/node_modules/pa11y-webservice/node_modules/mongodb/lib/mongodb/db.js:1442:27
    at /user/repo/pa11y-dashboard/node_modules/pa11y-webservice/node_modules/mongodb/lib/mongodb/db.js:1560:7
    at /user/repo/pa11y-dashboard/node_modules/pa11y-webservice/node_modules/mongodb/lib/mongodb/cursor.js:162:16
    at commandHandler (/user/repo/pa11y-dashboard/node_modules/pa11y-webservice/node_modules/mongodb/lib/mongodb/cursor.js:706:16)
    at /user/repo/pa11y-dashboard/node_modules/pa11y-webservice/node_modules/mongodb/lib/mongodb/db.js:1806:9
    at Server.Base._callHandler (/user/repo/pa11y-dashboard/node_modules/pa11y-webservice/node_modules/mongodb/lib/mongodb/connection/base.js:442:41)
    at /user/repo/pa11y-dashboard/node_modules/pa11y-webservice/node_modules/mongodb/lib/mongodb/connection/server.js:485:18
    at MongoReply.parseBody (/user/repo/pa11y-dashboard/node_modules/pa11y-webservice/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
8 Jun 20:38:06 - [nodemon] app crashed - waiting for file changes before starting...

Error starting Pa11y Webservice

I don't understand why the Webservice uri is 0.0.0.0 or why the connection is refused to localhost.

Any thoughts on debugging this?

MacBook:pa11y-webservice $ PORT=8080 node index.js

Pa11y Webservice started
mode: development
uri: http://0.0.0.0:3000

Error starting Pa11y Webservice:
connect ECONNREFUSED 127.0.0.1:27017

Update nyc to v15 or later

#95 was created to update nyc to v14, but this version has an issue with a config change that causes not all files to be tested. If I'm not mistaken, this has been corrected in v15.

Upgrading to v15 causes the coverage to fail though, so this will need to be corrected:

-----------|---------|----------|---------|---------|-------------------
File       | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------|---------|----------|---------|---------|-------------------
All files  |     100 |       75 |     100 |     100 |
 config.js |     100 |       75 |     100 |     100 | 18,28
-----------|---------|----------|---------|---------|-------------------
✓ test-unit-coverage done
ERROR: Coverage for branches (75%) does not meet global threshold (90%)
make: *** [verify-coverage] Error 1
npm ERR! Test failed.  See above for more details.

Update shields.io node version badge

The node version badge in the README currently points to the following URL:

https://img.shields.io/badge/node.js%20support-4–6-brightgreen.svg

This specifies the wrong version (should be >=8), and requires an update every time that support changes.

We should change the badge's URL so we use the version that automatically figures out the supported versions.

Use a logger which labels output

Currently the logging is done using console.log/console.error. We should really be using a configured logger (winston etc) that can also label the log output so that dual dashboard/webservice deployments can differentiate between the output.

i.e.

dashboard: Started on x.x.x.x
webservice: Starting on y.y.y.y

Add a changelog

It's about time we started tracking changes in this project properly. We can generate one based on commits to start us off, using the pa11y one as a template.

Replace async dependency with native async/await

As this project only supports LTS versions of node that include full support for async/await we should be able now to remove the async dependency which will reduce the size of our releases.

Although async doesn't have any (sub)dependencies, it takes around 700-800kB in size due to the fact that includes several concatenated versions of all the code.

Pagination

It would be handy if the webservice would be able to accommodate pagination. Either with prev/next functionality or splitting the tasks up alphabetically.

Add support for aXe runner

Pa11y (not currently published) now supports multiple test runners. We need to add the ability to select runners in the webservices.

Therse a couple of ways this could be done:

  • Specify a global runner(s) in the config
  • Specify the runner(s) for each site when it's added to the webservices
    • This would require additional work in the dashboard

Custom values on Task objects

Is there a way to add new keys and values to Task objects? I manually added Task objects with some extra values to categorize them, but the webservice didn't include these values when retrieving the objects.

Pa11y to test internal sites that are not on the internet but on intranet.

I installed the pa11y command line tool and am able to test any live site, I am wondering how I would go about testing development sites which can't be accessed outside of the network.

Error: PhantomJS failed to open "https://dev.test.cf.mytestsite.ca/foobar.html"
Error: Page "https://dev.test.cf.mytestsite.ca/foobar.html" could not be loaded
at /usr/local/lib/node_modules/pa11y/node_modules/truffler/lib/truffler.js:67:17
at Proto.apply (/usr/local/lib/node_modules/pa11y/node_modules/truffler/node_modules/phantom/node_modules/dnode/node_modules/dnode-protocol/index.js:123:13)
at Proto.handle (/usr/local/lib/node_modules/pa11y/node_modules/truffler/node_modules/phantom/node_modules/dnode/node_modules/dnode-protocol/index.js:99:19)
at D.dnode.handle (/usr/local/lib/node_modules/pa11y/node_modules/truffler/node_modules/phantom/node_modules/dnode/lib/dnode.js:140:21)
at D.dnode.write (/usr/local/lib/node_modules/pa11y/node_modules/truffler/node_modules/phantom/node_modules/dnode/lib/dnode.js:128:22)
at SockJSConnection.ondata (stream.js:51:26)
at SockJSConnection.emit (events.js:107:17)
at Session.didMessage (/usr/local/lib/node_modules/pa11y/node_modules/truffler/node_modules/phantom/node_modules/shoe/node_modules/sockjs/lib/transport.js:220:25)
at WebSocketReceiver.didMessage (/usr/local/lib/node_modules/pa11y/node_modules/truffler/node_modules/phantom/node_modules/shoe/node_modules/sockjs/lib/trans-websocket.js:102:40)
at /usr/local/lib/node_modules/pa11y/node_modules/truffler/node_modules/phantom/node_modules/shoe/node_modules/sockjs/lib/trans-websocket.js:75:22

Is there any way to install, pa11y as well as it's requirements onto a local server and run everything in house without any calls to outside?

Thank you for the help!

Question: can I call Pa11y API directly

Hello

I have been trying to generate accessibility reports by writing a node script, pa11y is catching many errors for my pages and I'm trying to incorporate it by getting the errors in json form.
the problem is that using the webservice is a lot of boilerplate for me I need to install it on machines of every person who will generate the report and have to start the server each time I want to generate data

I am trying to get accessibility data for public pages using pa11y, for lighthouse I have been using this API endpoint Page Speed insight with ACCESSIBILITY category

the question is there a similar API for pa11y?

Set the concurrency limit as environment variable

Currently, the concurrency limit for the cron job is set to 2 workers. Since in some cases some users don't not need to use too many resources and can get the job done wih only one worker, this number could be set using an environment variable.

task/pa11y.js

const queue = async.queue(function(task, nextInQueue) {
	console.log('Starting task %s', task.id);
	app.model.task.runById(task.id, function(error) {
		if (error) {
			console.log(chalk.red('Failed to finish task %s: %s'), task.id, error.message);
		} else {
			console.log(chalk.green('Finished task %s'), task.id);
		}
		nextInQueue();
	});
}, config.nWorkers);

I can make the change but I was wondering, What do you think about it?

Add unit tests for cron job

The cron job part of the code has no testing through unit or integration tests. Integration tests don't really make sense for something that runs on a schedule, so need some unit tests around this.

There has been some issues recently with the stability of that code, so we should definitely get a bit of resliaince in our build around this.

There is currently only one unit test in the entire project 😱 .

Returns 500 without explanation

In a couple of cases the webservices returns an HTTP 500 error without explanation.

Notably when you request a task with lastres: true and there is no last result, the web services simply replies with 500.

Breakage when trying to run pa11y-dashboard

I've been trying unsuccessfully to run pa11y-dashboard using the unpublished version of pa11y-webservice (as it's in the master branch). There seems to be two issues at the moment:

  • Failure to find the module joy: this may be related to 1097945
  • Failure to start pa11y-webservice: this looks related to 2d8a9a0

Allow posting html for auditing directly

I would like to propose an alternative POST body that would be supported in addition to the current POST body.

{
    "name": "my-name",
    "html": "<div>foo</div>",
    "standard": "WCAG2AA"
}

My use case is that I would like to catch a11y issues before they go out, so I would like to write a plugin for the text editor we use on the site (https://www.tiny.cloud/) that posts the contents of the editor on blur, and displays any a11y issues detected as validation errors on the form. This will allow us to alert users of a11y issues when they are authoring their page, and not after it has been released in production.

Website Logins

Hi. I'm new to using pa11y, and I have the webservice working locally. The site I'm testing has a login page to access any other URL.

Is there any way to add authentication when trying to reach URLs past the login form?

Is there also a way to pass a list of URLs to the service when the task is run?

Unable to start server

I have been unable to start the web service using the provided commands (NODE_ENV=test node .) after a fresh install with no errors. When I issue that command inside of the cloned pa11y directory, no messages are printed to the console (not even an error message). I have the proper configuration files for the environment as well.

Are there any other tricks to getting the web service started?

Error connecting to MongoDB

I don't think this is related to #115 but just wanted to link the two. Not sure why this isn't working for me.

$ PORT=8080 npm start

(node:26780) ExperimentalWarning: The fs.promises API is experimental

> [email protected] start
> node index.js

Error connecting to MongoDB:
{"name":"MongoError","message":"failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]"}

Pa11y Webservice started
mode:     undefined
uri:      http://0.0.0.0:8080
database: mongodb://localhost/pa11y-webservice
cron:     false

Error starting Pa11y Webservice:
failed to connect to server [localhost:27017] on first connect [MongoError: connect ECONNREFUSED 127.0.0.1:27017]

Mongodb username and password get logged on startup

Moving the issue here from pa11y/pa11y-dashboard#273 so we can track it properly.

I've noticed that when the dashboard starts, the mongo connection string is logged. When connecting to a mongo instance using username and password (e.g. mongodb://username:password@localhost/test) this means that the username and password are also logged.

Could the log line be removed, or perhaps just the database host name be logged instead?

Upgrade mongodb client to v3

If we want to upgrade MongoDB to v3 then we will have to have a think as it makes a change that the DB is not selected by default. One has to manually select the database using .db(name).
This means we will have to add a section to the configuration to pass this in, which will be a breaking change.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.