npm

npm’s 2019 JavaScript ecosystem survey analysis is now available! Get your copy here »

storybook-addon-storypa11y

0.0.9 • Public • Published

StoryPa11y

StoryShots adds automatic Jest Testing for Accessibility for Storybook. It uses pa11y in its testing suites.

To use StoryPa11y, you must use your existing Storybook stories as the input for Jest Testing.

Getting Started

Add the following module into your app.

npm install --save-dev storybook-addon-storypa11y

Quickstart

Create a file matching your jests test regex and add the following code:

import initStorypa11y from 'storybook-addon-storypa11y';
 
initStorypa11y();

This will create a test suite which tests all of your stories for accessibility.

Options

You can pass an options object to the initStorypa11y function which takes several keys: framework: 'react', configPath: path.join(__dirname, '..', '.storybook'), storyKindRegex: /^((?!.?Fail).)$/, out: 'storybook-static', test: pa11y,

framework

You can specify which storybook framework to use. Note that angular is currently not supported. Defaults to react.

configPath

Here you can specify the path to your storybook config file. This is required in order to initialize storybook correctly.

storyKindRegex

You can pass a regex to only include matching story kinds in accessibility testing.

storyNameRegex

You can pass a regex to only include matching stories in accessibility testing.

out

Relative path from the project root to the folder you build your storybook in. Defaults to storybook.

pa11yOptions

Options that will be passed directly to pa11y. See their documentation for what can be passed. Also check the default options set by StoryPa11y.

test

It is also possible to pass your own test function. See stories/failing.test.js for an example.

Credits

This addon is heavily based on the official storyshots addon and the amazing work done by all their contributors

install

npm i storybook-addon-storypa11y

Downloadsweekly downloads

12

version

0.0.9

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability