nielse63/launch-checklist

View on GitHub
lib/tests/accessibility.js

Summary

Maintainability
A
0 mins
Test Coverage

import pa11y from 'pa11y'

export default function (url) {
  const test = pa11y({
    ignore: [
      'notice',
      'warning',
    ],
  })

  return new Promise((resolve, reject) => {
    test.run(url, (err, data) => {
      if (err) {
        return reject(err)
      }

      const info = [...new Set(data.map(msg => msg.message))]
      resolve({
        passed: !info.length,
        reason: `This page does not meet the WCAG 2.0 recommendations - ${info.length} unique issues found`,
        info,
      })
    })
  })
}