@etchteam/storybook-addon-a11y-interaction-tests

中文文档
2.0.1发布于 2026/02/16MITTypeScriptES Module构建来源已验证近 30 天下载 3100

Storybook addon for accessibility interaction tests

原始使用文档
文档目录6 节
  1. Installation
  2. Usage
  3. Example Usage
  4. Using Multiple Test Patterns
  5. Available Tests
  6. License

Storybook A11y Interaction Tests

A collection of reusable accessibility interaction tests for common UI patterns that can be used in Storybook's test runner play functions.

Installation

npm install --save-dev @etchteam/storybook-addon-a11y-interaction-tests
# or
yarn add -D @etchteam/storybook-addon-a11y-interaction-tests

Usage

This addon provides a set of reusable accessibility interaction tests that you can use in your Storybook stories' play functions. The tests follow the W3C ARIA Design Patterns and test for proper ARIA roles, states, properties, and keyboard interactions.

Example Usage

import type { Meta, StoryObj } from '@storybook/react';
import { expect, userEvent } from '../utils/test-utils';
import { a11yButton } from '@etchteam/storybook-addon-a11y-interaction-tests';

import { Button } from './Button';

const meta: Meta<typeof Button> = {
  component: Button,
  argTypes: {
    // ... your argTypes
  },
};

export default meta;
type Story = StoryObj<typeof Button>;

export const Primary: Story = {
  args: {
    label: 'Button',
    primary: true,
  },
  play: async ({ canvasElement, step }) => {
    // Run the a11y button tests
    await a11yButton({
      step,
      canvasElement,
      isDisabled: false,
      isToggle: false,
    });
    
    // Add any additional tests specific to your button component
  },
};

export const Disabled: Story = {
  args: {
    label: 'Disabled Button',
    disabled: true,
  },
  play: async ({ canvasElement, step }) => {
    await a11yButton({
      step,
      canvasElement,
      isDisabled: true,
    });
  },
};

Using Multiple Test Patterns

You can use multiple accessibility tests for components that combine patterns:

import { a11yButton, a11yDisclosure } from '@etchteam/storybook-addon-a11y-interaction-tests';

// ...

export const DisclosureButton: Story = {
  args: {
    // ...
  },
  play: async ({ canvasElement, step }) => {
    // Test both button and disclosure aspects
    await a11yButton({ step, canvasElement });
    await a11yDisclosure({ step, canvasElement });
  },
};

Available Tests

This addon includes tests for the following ARIA patterns:

  • a11yAccordion - Tests for accordion components
  • a11yAlert - Tests for alert components
  • a11yAlertDialog - Tests for alert dialog components
  • a11yButton - Tests for button components
  • a11yCarousel - Tests for carousel components
  • a11yCheckbox - Tests for checkbox components
  • a11yCombobox - Tests for combobox components
  • a11yDisclosure - Tests for disclosure components
  • a11yLink - Tests for link components
  • a11yModal - Tests for modal dialog components
  • a11yRadio - Tests for radio button components
  • a11ySwitch - Tests for switch components
  • a11yTable - Tests for table components
  • a11yTabs - Tests for tabs components

Each test function accepts parameters specific to that component type.

License

MIT

版本与发布记录

@etchteam/storybook-addon-a11y-interaction-tests 共发布 14 个版本,首次发布于 2025/04/01;过去 12 个月发布了 1 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.0.1latest2026/02/168 个月前
2.0.02025/07/281.3 年前
1.0.02025/06/171.4 年前
0.3.02025/04/011.6 年前
0.2.52025/04/011.6 年前
0.2.42025/04/011.6 年前

关于 @etchteam/storybook-addon-a11y-interaction-tests 的常见问题

@etchteam/storybook-addon-a11y-interaction-tests 是什么?

Storybook addon for accessibility interaction tests

如何安装 @etchteam/storybook-addon-a11y-interaction-tests?

在项目目录运行 npm install @etchteam/storybook-addon-a11y-interaction-tests,或使用 pnpm add / yarn add / bun add。

@etchteam/storybook-addon-a11y-interaction-tests 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@etchteam/storybook-addon-a11y-interaction-tests 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@etchteam/storybook-addon-a11y-interaction-tests 可以商用吗?

@etchteam/storybook-addon-a11y-interaction-tests 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@etchteam/storybook-addon-a11y-interaction-tests 的下载量有多少?

根据 npm 官方下载统计,@etchteam/storybook-addon-a11y-interaction-tests 在 2026/10/14 – 2026/11/12 这 30 天内被下载 3,100 次,日均约 103 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@etchteam/storybook-addon-a11y-interaction-tests 还在维护吗?

最新版本 2.0.1 发布于 2026/02/16(8 个月前);至今共发布 14 个版本,其中过去 12 个月发布了 1 个;首次发布于 2025/04/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。