Skip to content

Latest commit

 

History

History
 
 

storybook-a11y-test

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

@shopify/storybook-a11y-test

Build Status Build Status License: MIT npm version npm bundle size (minified + gzip)

Test storybook pages with axe and puppeteer.

Installation

$ yarn add @shopify/storybook-a11y-test

Usage

Make sure you have built your storybook instance and there is an iframe.html file that you can point the test towards.

const {testPages, getCurrentStoryIds} = require('./built-a11y-package');

(async () => {
  const iframePath = `file://${__dirname}/../build/storybook/static/iframe.html`;
  const timeout = 1000;
  const storyIds = await getCurrentStoryIds({iframePath, skippedStoryIds: []});
  const results = await testPages({iframePath, storyIds, timeout});

  if (results.length) {
    console.error(`‼️  Test failures found`);
    console.log(results.join('\n'));
    process.exit(1);
  } else {
    console.log('🧚‍♀️ Accessibility is all g');
  }
})();

API

getCurrentStoryIds(options)

iframePath string

The location of the built storybook iframe.html file.

skippedStoryIds array (optional)

An array of storybook id's to skip.

testPages(options)

iframePath string

The location of the built storybook iframe.html file.

storyIds

An array of storybook id's to run. These can be retrieved via the getCurrentStoryIds() function.

concurrentCount number (optional)

The number of tabs to open in chromium. The default option is based off the number of CPU cores available os.cpus().length.

timeout number (optional)

The goto timeout for the provided url. Defaults to 3000 (puppeteer default)