Have ideas to improve npm?Join in the discussion! »

    @shopify/storybook-a11y-test
    TypeScript icon, indicating that this package has built-in type declarations

    0.2.1 • Public • Published

    @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)

    Keywords

    none

    Install

    npm i @shopify/storybook-a11y-test

    DownloadsWeekly Downloads

    11,241

    Version

    0.2.1

    License

    MIT

    Unpacked Size

    24.3 kB

    Total Files

    14

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar