Skip to content

Latest commit

History

History
38 lines (25 loc) 路 1.33 KB

use-storybook-testing-library.md

File metadata and controls

38 lines (25 loc) 路 1.33 KB

Use storybook testing library package (use-storybook-testing-library)

Included in these configurations:

  • addon-interactions
  • recommended

Rule Details

Storybook provides an instrumented version of testing library in the @storybook/testing-library package. When writing interactions, make sure to use the helper functions from @storybook/testing-library, so that addon-interactions can intercept these helper functions and allow you to step through them when debugging.

Examples of incorrect code for this rule:

// wrong import!
import { within } from '@testing-library/react'

Default.play = async (context) => {
  const canvas = within(context.canvasElement)
}

Examples of correct code for this rule:

// correct import.
import { within } from '@storybook/testing-library'

Default.play = async (context) => {
  const canvas = within(context.canvasElement)
}

When Not To Use It

This rule should not be applied in test files. Please ensure you are defining the storybook rules only for story files. You can see more details here.