Socket
Socket
Sign inDemoInstall

@storybook/test

Package Overview
Dependencies
Maintainers
11
Versions
426
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storybook/test


Version published
Weekly downloads
2.1M
decreased by-3.78%
Maintainers
11
Weekly downloads
 
Created

Changelog

Source

8.1.1

  • Docgen: Only add react-docgen info when a component is defined in the file - #26967, thanks @glenjamin!
  • Docs: Fix MDX Stories block tag-filtering behavior - #27144, thanks @shilman!
  • Docs: Fix Subtitle block when no of prop passed - #27147, thanks @JReinhold!
  • Next.js: Add typing for NextImage to main framework options type - #27105, thanks @valentinpalkovic!
  • Next.js: Avoid conflicts with the raw loader - #27093, thanks @seanparmelee!
  • Types: Fix typing for main.framework/builder fields - #27088, thanks @valentinpalkovic!

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

Package last updated on 15 May 2024

Did you know?

Socket

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
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc