# @storybook/test

Latest version **8.6.15** (published 2025-12-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @storybook/test
pnpm add @storybook/test
yarn add @storybook/test
bun add @storybook/test
```

## Health

**Score 70/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 8.6.15 |
| Published | 2025-12-17 |
| First published | 2023-08-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 7 |
| Unpacked size | 1.7 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 91152 |
| Maintainers | ndelangen, shilman, tmeasday, ghengeveld, winkervsbecks, yannbf, kylegach, jreinhold, kasperpeulen, valentinpalkovic, domyen, storybook-bot |
| Keywords | storybook |

## Links

- npm: https://www.npmjs.com/package/@storybook/test
- Repository: https://github.com/storybookjs/storybook
- Homepage: https://github.com/storybookjs/storybook/tree/next/code/lib/test
- Issues: https://github.com/storybookjs/storybook/issues
- Funding: https://opencollective.com/storybook
- npm.io page: https://npm.io/package/@storybook/test

## Dependencies (7)

- [@vitest/spy](https://npm.io/package/@vitest/spy.md) 2.0.5
- [@vitest/expect](https://npm.io/package/@vitest/expect.md) 2.0.5
- [@storybook/global](https://npm.io/package/@storybook/global.md) ^5.0.0
- [@testing-library/dom](https://npm.io/package/@testing-library/dom.md) 10.4.0
- [@storybook/instrumenter](https://npm.io/package/@storybook/instrumenter.md) 8.6.15
- [@testing-library/jest-dom](https://npm.io/package/@testing-library/jest-dom.md) 6.5.0
- [@testing-library/user-event](https://npm.io/package/@testing-library/user-event.md) 14.5.2

## Recent versions

- 8.6.15 (latest) — 2025-12-17
- 7.6.24 (v7) — 2026-03-06
- 8.6.18 (v8) — 2026-03-06
- 0.0.0-pr-34011-sha-c45b0f3f (v7-canary) — 2026-03-06
- 0.0.0-pr-34009-sha-c90626e7 (v8-canary) — 2026-03-04
- 0.0.0-pr-31494-sha-c99bda03 (canary) — 2025-05-16
- 9.0.0-alpha.2 (next) — 2025-03-05
- 8.2.10 (tag-for-publishing-older-releases) — 2024-11-04
- 0.0.0-pr-34011-sha-1f3f0b01 — 2026-03-04
- 8.6.17 — 2026-02-18
- 7.6.23 — 2026-02-18
- 0.0.0-pr-33859-sha-95913f7f — 2026-02-17
- 0.0.0-pr-33859-sha-2907ae70 — 2026-02-17
- 0.0.0-pr-33859-sha-3b5f3a7d — 2026-02-17
- 0.0.0-pr-33859-sha-13cfcf7c — 2026-02-17
- … 749 more at https://npm.io/package/@storybook/test/versions

## README

# Storybook Test

The `@storybook/test` package contains utilities for testing your stories inside `play` functions.

## Installation

Install the package by adding the `@storybook/test` dev dependency:

```sh
npm install -D @storybook/test
pnpm add -D @storybook/test
yarn add -D @storybook/test
```

Note that this package is not an addon, so you don't have to add it to your `main.js/main.ts` file.

## Usage

The test package exports instrumented versions of [@vitest/spy](https://vitest.dev/api/mock.html), [@vitest/expect](https://vitest.dev/api/expect.html) (based on [chai](https://www.chaijs.com/)), [@testing-library/dom](https://testing-library.com/docs/dom-testing-library/intro) and [@testing-library/user-event](https://testing-library.com/docs/user-event/intro).
The instrumentation makes sure you can debug those methods in the [addon-interactions](https://storybook.js.org/addons/@storybook/addon-interactions) panel.

```ts
// Button.stories.ts
import { expect, fn, userEvent, within } from '@storybook/test';
import { Button } from './Button';

export default {
  component: Button,
  args: {
    onClick: fn(),
  },
};

export const Demo = {
  play: async ({ args, canvasElement }) => {
    const canvas = within(canvasElement);
    await userEvent.click(canvas.getByRole('button'));
    await expect(args.onClick).toHaveBeenCalled();
  },
};
```

---
_Source: https://npm.io/package/@storybook/test · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
