Importing and Initializing Puppeteer for JavaScript

Link to Importing and Initializing Puppeteer for JavaScript copied to clipboard

Importing and initializing the axe DevTools for Web Puppeteer JavaScript package (@axe-devtools/puppeteer)

Once you've installed axe DevTools for Web, you need to import it into your testing setup and initialize the package.

Prerequisites

In order to import and initialize axe DevTools for Web, it needs to be installed first. If you haven't yet, read the guide on how to install it from a bundle, from your artifact repository, or from Deque's Agora. You will also need Puppeteer installed.

Importing and Initializing

Outside of a module, axe DevTools for Web is imported and an instance created with a statement like this:

const { AxeDevToolsPuppeteer } = require('@axe-devtools/puppeteer');

Importing Puppeteer will be required as well:

const puppeteer = require('puppeteer');

Within a module, the syntax is slightly different. The statement should look like this:

import { AxeDevToolsPuppeteer } from '@axe-devtools/puppeteer';

Importing Puppeteer will be required as well:

import puppeteer from 'puppeteer';

For each scan, a new AxeDevToolsPuppeteer object will be created. To see how to do this, see the guide on writing tests.

Next Steps

Once you've installed, imported, and initialized axe DevTools for Web, you're ready to move on to scanning for accessibility and writing accessibility tests. To do that, see the guide on writing tests.

Troubleshooting

If you have trouble with any of the importing or initializing of axe DevTools for Web, contact your Deque representative directly, reach us via our support desk, or send us an email. We'll be happy to help.