Included in these configurations:
- addon-interactions
- flat/addon-interactions
- recommended
- flat/recommended
Storybook provides a browser compatible version of expect
via the @storybook/test library (formerly available in the legacy @storybook/jest library).
When writing interactions and asserting values, you should always use expect
from the @storybook/test
library.
Examples of incorrect code for this rule:
Default.play = async () => {
// using global expect from Jest. Will break on the browser
await expect(123).toEqual(123)
}
Examples of correct code for this rule:
// correct import.
import { expect } from '@storybook/test'
// or this, which is now considered legacy
import { expect } from '@storybook/jest'
Default.play = async () => {
// using imported expect from storybook package
await expect(123).toEqual(123)
}
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.