Code Monkey home page Code Monkey logo

lumberjack's Introduction

Lumberjack

Chop down accessibility issues with this full-website accessibility scanner

Woman in winter attire standing with an ax next to a tree

About

Lumberjack runs axe accessibility checks on your entire website!

  • Reads your website's sitemap
  • Spawns multiple browser instances and starts scanning with axe
  • Aggregates results and reports back

    Screenshot of lumberjack in action. Print the individual accessibility issues found in an example

Usage

CLI

NPX (recommended for a single run)

npx @jakepartusch/lumberjack --url https://google.com

Global Install (recommended for multiple runs)

npm install -g @jakepartusch/lumberjack
lumberjack --url https://google.com

Options

--url         // Required — The base url to scan. If a sitemap exists, its pages will be scanned as well
--strict      // Optional (default: false) — Fail the process if any accessibility issues are found
--baseUrlOnly // Optional (default: false) — Skip the sitemap scan and only run the audit on the base url

JavaScript

npm install @jakepartusch/lumberjack
const lumberjack = require('@jakepartusch/lumberjack');

const myFunction = async () => {
  const results = await lumberjack("https://google.com");
  console.log(results);
}

Continuous Integration

GitHub Actions Example (eg. ".github/workflows/accessibility.yml")

name: Accessibility Audits

on: [push]

jobs:
  build:
    runs-on: ubuntu-18.04

    steps:
      - uses: actions/checkout@v1
      - name: Install required Linux packages
        run: |
          sudo apt-get update
          sudo apt-get install libgbm-dev
          sudo apt-get install xvfb
      - name: Use Node.js 12.x
        uses: actions/setup-node@v1
        with:
          node-version: 12.x
      - name: Install npm packages
        run: |
          npm ci
      - name: Build
        run: |
          npm run build
      - name: Accessibility Audits
        run: |
          npm install -g @jakepartusch/lumberjack
          xvfb-run --auto-servernum lumberjack --url https://google.com

lumberjack's People

Contributors

dependabot[bot] avatar jakepartusch avatar quinnturner 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

lumberjack's Issues

Protocol error (Target.getBrowserContexts): Target closed.

I'm not very experienced at JS or npm, but I thought I'd give this a try. Unfortunately, putting it together in a fresh Vagrant box seemed to give me the error below.

I'm not sure whether this represents a problem with this package, playwright, or maybe how playwright's underlying browser instances are behaving with the virtual framebuffer?

In any case it seemed like it might be useful to post it here.

Steps to reproduce:
# In a new directory, as usual for Vagrant
vagrant init ubuntu/bionic64
vagrant up
vagrant ssh
sudo su
# Getting a more up-to-date version of node
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt-get update
apt-get install -y nodejs build-essential xvfb libgbm-dev nodejs
# --unsafe-perm=true seems to be needed for the playwright package install?
# Otherwise you get a "permission denied" error.
npm install -g @jakepartusch/lumberjack --unsafe-perm=true

Then:

$ xvfb-run --auto-servernum lumberjack --url https://google.com
⠋ Running accessibility checks... (1 of 100 pages){ Error: Protocol error (Target.getBrowserContexts): Target closed.
    at Promise (/usr/lib/node_modules/@jakepartusch/lumberjack/node_modules/playwright-core/lib/chromium/crConnection.js:121:63)
    at new Promise (<anonymous>)
    at CRSession.send (/usr/lib/node_modules/@jakepartusch/lumberjack/node_modules/playwright-core/lib/chromium/crConnection.js:120:16)
    at Function.connect (/usr/lib/node_modules/@jakepartusch/lumberjack/node_modules/playwright-core/lib/chromium/crBrowser.js:48:68)
  message: 'Protocol error (Target.getBrowserContexts): Target closed.' }

Oh, and, since it might be relevant, here's the error I get with the npm install step if I repeat the setup steps but don't use --unsafe-perm=true:

(node:8999) UnhandledPromiseRejectionWarning: Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/@jakepartusch/lumberjack/node_modules/playwright-core/.local-chromium'
(node:8999) 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(). (rejection id: 1)
(node:8999) [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.
+ @jakepartusch/[email protected]
added 132 packages from 171 contributors in 7.941s
⠏ Fetching sitemapError: Chromium revision is not downloaded. Run "npm install"
    at Chromium.launchBrowserApp (/usr/lib/node_modules/@jakepartusch/lumberjack/node_modules/playwright-core/lib/server/chromium.js:70:23)

Lumberjack not working when the server has a Content-Security-Policy set

When the server to contact has a CSP header set that does not include Cloudflare, it stops working with the following stacktrace:

❯ lumberjack --url https://uberspace.de
⠦ Running accessibility checks... (1 of 1 pages)Error: Refused to load the script 'https://cdnjs.cloudflare.com/ajax/libs/axe-core/3.4.2/axe.min.js' because it violates the following Content Security Policy directive: "script-src 'self' https://dashboard.uberspace.de https://*.uberspace.is https://analyti.uber.space". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.

    at Frame._raceWithCSPError (/home/jlnostr/.npm-packages/lib/node_modules/@jakepartusch/lumberjack/node_modules/playwright-core/lib/frames.js:587:19)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async runAccessibilityTestsOnUrl (/home/jlnostr/.npm-packages/lib/node_modules/@jakepartusch/lumberjack/index.js:23:3)
    at async Promise.all (index 0)
    at async runAllChecks (/home/jlnostr/.npm-packages/lib/node_modules/@jakepartusch/lumberjack/index.js:62:38)
    at async main (/home/jlnostr/.npm-packages/lib/node_modules/@jakepartusch/lumberjack/bin/cli.js:30:33)
  -- ASYNC --
    at Frame.<anonymous> (/home/jlnostr/.npm-packages/lib/node_modules/@jakepartusch/lumberjack/node_modules/playwright-core/lib/helper.js:54:23)
    at Page.addScriptTag (/home/jlnostr/.npm-packages/lib/node_modules/@jakepartusch/lumberjack/node_modules/playwright-core/lib/page.js:132:33)
    at Page.<anonymous> (/home/jlnostr/.npm-packages/lib/node_modules/@jakepartusch/lumberjack/node_modules/playwright-core/lib/helper.js:55:31)
    at runAccessibilityTestsOnUrl (/home/jlnostr/.npm-packages/lib/node_modules/@jakepartusch/lumberjack/index.js:23:14)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Promise.all (index 0)
    at async runAllChecks (/home/jlnostr/.npm-packages/lib/node_modules/@jakepartusch/lumberjack/index.js:62:38)
    at async main (/home/jlnostr/.npm-packages/lib/node_modules/@jakepartusch/lumberjack/bin/cli.js:30:33)

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.