Skip to content

Latest commit

History

History
40 lines (26 loc) 路 1.29 KB

use-storybook-expect.md

File metadata and controls

40 lines (26 loc) 路 1.29 KB

Use expect from '@storybook/jest' (use-storybook-expect)

Included in these configurations:

  • addon-interactions
  • recommended

Rule Details

Storybook provides a browser compatible version of Jest's expect via the @storybook/jest library. When writing interactions and asserting values, you should always use expect from the @storybook/jest library.

Examples of incorrect code for this rule:

Default.play = () => {
  // using global expect from Jest. Will break on the browser
  expect(123).toEqual(123)
}

Examples of correct code for this rule:

import { expect } from '@storybook/jest'

Default.play = () => {
  // using imported expect from storybook package
  expect(123).toEqual(123)
}

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.

Further Reading

If there are other links that describe the issue this rule addresses, please include them here in a bulleted list.