# @junk-temporary-prototypes/addon-interactions

> Automate, test and debug user interactions

Latest version **7.2.5** (published 2023-06-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @junk-temporary-prototypes/addon-interactions
pnpm add @junk-temporary-prototypes/addon-interactions
yarn add @junk-temporary-prototypes/addon-interactions
bun add @junk-temporary-prototypes/addon-interactions
```

## Health

**Score 50/100 (C)** — status: abandoned.

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

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 7.2.5 |
| Published | 2023-06-08 |
| First published | 2023-05-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 13 |
| Unpacked size | 139.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 91630 |
| Maintainers | kasperpeulen, jreinhold |
| Keywords | storybook-addons, data-state, test |

## Links

- npm: https://www.npmjs.com/package/@junk-temporary-prototypes/addon-interactions
- Repository: https://github.com/storybookjs/storybook
- Homepage: https://github.com/storybookjs/storybook/tree/next/code/addons/interactions
- Issues: https://github.com/storybookjs/storybook/issues
- Funding: https://opencollective.com/storybook
- npm.io page: https://npm.io/package/@junk-temporary-prototypes/addon-interactions

## Dependencies (13)

- [polished](https://npm.io/package/polished.md) ^4.2.2
- [jest-mock](https://npm.io/package/jest-mock.md) ^27.0.6
- [ts-dedent](https://npm.io/package/ts-dedent.md) ^2.2.0
- [@storybook/global](https://npm.io/package/@storybook/global.md) ^5.0.0
- [@junk-temporary-prototypes/types](https://npm.io/package/@junk-temporary-prototypes/types.md) 7.2.5
- [@junk-temporary-prototypes/theming](https://npm.io/package/@junk-temporary-prototypes/theming.md) 7.2.5
- [@junk-temporary-prototypes/components](https://npm.io/package/@junk-temporary-prototypes/components.md) 7.2.5
- [@junk-temporary-prototypes/core-common](https://npm.io/package/@junk-temporary-prototypes/core-common.md) 7.2.5
- [@junk-temporary-prototypes/core-events](https://npm.io/package/@junk-temporary-prototypes/core-events.md) 7.2.5
- [@junk-temporary-prototypes/manager-api](https://npm.io/package/@junk-temporary-prototypes/manager-api.md) 7.2.5
- [@junk-temporary-prototypes/preview-api](https://npm.io/package/@junk-temporary-prototypes/preview-api.md) 7.2.5
- [@junk-temporary-prototypes/instrumenter](https://npm.io/package/@junk-temporary-prototypes/instrumenter.md) 7.2.5
- [@junk-temporary-prototypes/client-logger](https://npm.io/package/@junk-temporary-prototypes/client-logger.md) 7.2.5

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 7.2.5 (latest) — 2023-06-08
- 7.2.0-pr-47-60d512b.0 (pr-47) — 2023-07-06
- 7.2.1 (next) — 2023-06-07
- 7.2.0-pr-46-b35a952.0 (pr-46) — 2023-06-06
- 7.2.0-pr-43-e055456.0 (pr-43) — 2023-06-05
- 7.2.0-pr-40-asdf123.0 (pr-40) — 2023-06-01
- 7.0.8-alpha.4 (next}) — 2023-05-25
- 7.1.0-beta.2 (beta) — 2023-05-01
- 7.1.0-alpha.1 (alpha) — 2023-05-01
- 7.2.4 — 2023-06-08
- 7.2.3 — 2023-06-08
- 7.2.2 — 2023-06-08
- 7.2.0 — 2023-06-06
- 7.2.0-pr-43-b6a1f17.0 — 2023-06-05
- 7.2.0-pr-43-3a3d678.0 — 2023-06-05
- … 16 more at https://npm.io/package/@junk-temporary-prototypes/addon-interactions/versions

## README

# Storybook Addon Interactions

Storybook Addon Interactions enables visual debugging of interactions and tests in [Storybook](https://storybook.js.org).

![Screenshot](https://user-images.githubusercontent.com/321738/135628189-3d101cba-50bc-49dc-bba0-776586fedaf3.png)

## Installation

Install this addon by adding the `@storybook/addon-interactions` dependency:

```sh
yarn add -D @storybook/addon-interactions @storybook/jest @storybook/testing-library
```

within `.storybook/main.js`:

```js
export default {
  addons: ['@storybook/addon-interactions'],
};
```

Note that `@storybook/addon-interactions` must be listed **after** `@storybook/addon-actions` or `@storybook/addon-essentials`.

## Usage

Interactions relies on "instrumented" versions of Jest and Testing Library, that you import from `@storybook/jest` and
`@storybook/testing-library` instead of their original package. You can then use these libraries in your `play` function.

```js
import { Button } from './Button';
import { expect } from '@storybook/jest';
import { within, userEvent } from '@storybook/testing-library';

export default {
  title: 'Button',
  component: Button,
  argTypes: {
    onClick: { action: true },
  },
};

const Template = (args) => <Button {...args} />;

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

In order to enable step-through debugging, calls to `userEvent.*`, `fireEvent`, `findBy*`, `waitFor*` and `expect` have to
be `await`-ed. While debugging, these functions return a Promise that won't resolve until you continue to the next step.

While you can technically use `screen`, it's recommended to use `within(canvasElement)`. Besides giving you a better error
message when a DOM element can't be found, it will also ensure your play function is compatible with Storybook Docs.

Any `args` that are marked as an `action` (typically via `argTypes` or `argTypesRegex`) will be automatically wrapped in
a [Jest mock function](https://jestjs.io/docs/jest-object#jestfnimplementation) so you can assert invocations. See
[addon-actions](https://storybook.js.org/docs/react/essentials/actions) for how to setup actions.

---
_Source: https://npm.io/package/@junk-temporary-prototypes/addon-interactions · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
