Last active
July 12, 2018 11:51
-
-
Save matthewblewitt/1c47e7dfd598c7ee6c56be6454e5d5ba to your computer and use it in GitHub Desktop.
pa11y automated accessibility testing with mocha
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pa11y = require('pa11y'); | |
const request = require('supertest'); | |
const mocha = require('mocha'); | |
const { expect } = require('chai'); | |
const server = require('./server'); | |
const url = | |
process.env.NODE_ENV === 'testing' | |
? 'http://localhost:3000' | |
: 'http://example.com'; | |
describe('my page', function() { | |
it('is accessible', function(done) { | |
pa11y(`${url}/`, function(err, results) { | |
expect(results.issues).to.be.empty; | |
done(); | |
}); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pa11y = require('pa11y'); | |
const mocha = require('mocha'); | |
const path = require('path'); | |
const { expect } = require('chai'); | |
const pages = ['test.html', 'test2.html', 'test3.html']; | |
describe('Pages', function() { | |
pages.forEach(page => { | |
it(`${page} should be accessible`, function(done) { | |
pa11y(path.join(__dirname, page)) | |
.then(results => { | |
expect(results.issues).to.be.empty; | |
}) | |
.then(done, done) | |
.catch(err => { | |
console.log(err); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment