code/lib/eslint-plugin/docs/rules/await-interactions.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 an instrumented version of the testing library in the storybook/test core package (formerly available in @storybook/testing-library). When writing interactions, make sure to await them, 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:
import { userEvent, within } from "storybook/test";
// or from the legacy package "@storybook/testing-library";
MyStory.play = (context) => {
const canvas = within(context.canvasElement);
// not awaited!
userEvent.click(canvas.getByRole("button"));
};
Examples of correct code for this rule:
import { userEvent, within } from "storybook/test";
// or from the legacy package "@storybook/testing-library";
MyStory.play = async (context) => {
const canvas = within(context.canvasElement);
// awaited 👍
await userEvent.click(canvas.getByRole("button"));
};
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.