# storywright

> Storybook setup.

Latest version **0.0.27-storybook7.14** (published 2025-03-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install storywright
pnpm add storywright
yarn add storywright
bun add storywright
```

Provides the command `storywright`.

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.27-storybook7.14 |
| Published | 2025-03-25 |
| First published | 2021-07-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 190.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | sunilsurana |

## Links

- npm: https://www.npmjs.com/package/storywright
- npm.io page: https://npm.io/package/storywright

## Dependencies (3)

- [yargs](https://npm.io/package/yargs.md) ^16.2.0
- [playwright](https://npm.io/package/playwright.md) ^1.34.3
- [prop-types](https://npm.io/package/prop-types.md) ^15.6.0

## Recent versions

- 0.0.27-storybook7.14 (latest) — 2025-03-25
- 0.0.27-storybook7.3 (beta) — 2023-06-23
- 0.0.27-storybook7.13 — 2025-02-28
- 0.0.27-storybook7.12 — 2025-02-25
- 0.0.27-storybook7.11 — 2025-02-11
- 0.0.27-storybook7.10 — 2025-02-10
- 0.0.34 — 2024-03-19
- 0.0.33 — 2024-03-19
- 0.0.27-storybook7.9 — 2023-12-14
- 0.0.27-storybook7.8 — 2023-09-08
- 0.0.27-storybook7.7 — 2023-09-06
- 0.0.27-storybook7.6 — 2023-09-04
- 0.0.32 — 2023-08-18
- 0.0.27-storybook7.5 — 2023-07-31
- 0.0.27-storybook7.4 — 2023-07-31
- … 38 more at https://npm.io/package/storywright/versions

## README

# Storywright

Storywright is a tool to capture screenshots for React Storybook using Playwright. 

## How it works

Storywright works alongside Storybook to produce screenshots of the stories. In addition, it has capability to interact with the stories by clicking, hovering, waiting and many more actions.

Storywright exposes a React component, <StoryWright>, which can be added as a decorator in stories. For eg: 

If we have a button component, <Button />, and a story around that component, Button.stories.tsx, then:

In Button.stories.tsx:

```bash
const StoryWrightDemo = (story) => 
    <StoryWright>
        {story()}
    </StoryWright>
}

export default {
    title: "Button",
    decorators: [StoryWrightDemo]
}

export const ButtonStory = () => <Button></Button>
```

Above code will take screenshot of the whole page where <Button> is rendered.

### Testing Interactions
To test interactions, you can add Steps to each state to interact with the UI. This is useful for clicking buttons, filling out forms, and getting the UI into the proper visual state to test.

Here is an same example as above with interactions:

```bash
const StoryWrightDemo = (story) => 
    <StoryWright
        steps={new Steps()
        click('.btn')
        .snapshot('snapshot1')
        .end()}
    >
        {story()}
    </StoryWright>
}

export default {
    title: "Button",
    decorators: [StoryWrightDemo]
}

export const ButtonStory = () => <Button></Button>
```

Following methods are currently available:

- `click(selector: string)`
- `snapshot(filename: string)`
- `hover(selector: string)`
- `mouseUp(selector: string)`
- `mouseDown(selector: string)`
- `setValue(selector: string, value: string)`
- `keys(selector: string, keys: string)`
- `focus(selector: string)`
- `executeScript(code: string)`
- `wait(selector: string)`
- `waitForNotFound(selector: string)`
- `click(selector)`
- `waitForTimeout(millisecs: number)`

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