code/lib/eslint-plugin/docs/rules/use-storybook-expect.md
Included in these configurations: <ul><li>addon-interactions</li><li>flat/addon-interactions</li><li>recommended</li><li>flat/recommended</li></ul>
<!-- RULE-CATEGORIES:END -->Storybook provides a browser-compatible version of expect via the storybook/test core package (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 that you define the Storybook rules only for story files. You can see more details here.