Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var jsdom = require('jsdom');
- // Some html page
- var html = [
- '<html>',
- '<body>',
- '<p>An image without an alt tag! <img src="some.jpg" /></p>',
- '<h2>Not an h1</h2>',
- '<h5>blabla</h5>',
- '<h4></h4>',
- '</body>',
- '</html>'
- ].join('\n');
- jsdom.env(html, function(err, window) {
- // Make the `window` object globally available as axe-core assumes a
- // a browser context
- global.window = window;
- // Make the `Node` and `NodeList` classes globally available
- global.Node = window.Node;
- global.NodeList = window.NodeList;
- // Only now can `axe-core` be required as it checks for the `window`
- // object on module initialization
- // TODO: axe uses `document.createRange` which is not available through `jsdom`
- var axe = require('axe-core');
- // Run the checks
- axe.a11yCheck(window.document, function(data) {
- console.log(data);
- });
- });
Add Comment
Please, Sign In to add comment