Socket
Socket
Sign inDemoInstall

@storybook/test

Package Overview
Dependencies
12
Maintainers
8
Versions
295
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @storybook/test


Version published
Weekly downloads
1.6M
increased by4.34%
Maintainers
8
Install size
20.4 MB
Created
Weekly downloads
 

Changelog

Source

7.6.10

  • CLI: Fix existing version detection in upgrade - #25642, thanks @JReinhold!
  • React: Fix acorn ecma version warning - #25634, thanks @dannyhw!

Readme

Source

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:

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, @vitest/expect (based on chai), @testing-library/dom and @testing-library/user-event. The instrumentation makes sure you can debug those methods in the addon-interactions panel.

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

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();
  },
};

Keywords

FAQs

Last updated on 18 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc