Skip to content

Latest commit

History

History
39 lines (26 loc) 路 1.34 KB

await-interactions.md

File metadata and controls

39 lines (26 loc) 路 1.34 KB

await-interactions

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 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 { within, userEvent } from '@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 { within, userEvent } from '@storybook/testing-library'

MyStory.play = async (context) => {
  const canvas = within(context.canvasElement)
  // awaited 馃憤
  await userEvent.click(canvas.getByRole('button'))
}

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.