fbredius/storybook

View on GitHub
docs/snippets/angular/my-component-play-function-with-clickevent.mdx.mdx

Summary

Maintainability
Test Coverage
```md
<!-- MyComponent.stories.mdx -->

import { Meta, Story } from '@storybook/addon-docs';

import { fireEvent, screen, userEvent } from '@storybook/testing-library';

import { MyComponent } from './MyComponent.component';

<Meta title="ClickExamples" component={MyComponent} />

export const Template = (args) => ({ props: args });

<Story
  name="ClickExample"
  play={async () => {
    // See https://storybook.js.org/docs/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
    await userEvent.click(screen.getByRole('button'));
  }}>
  {Template.bind({})}
</Story>

<Story
  name="FireEventExample"
  play={async () => {
    // See https://storybook.js.org/docs/angular/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
    await fireEvent.click(screen.getByTestId('data-testid'));
  }}>
  {Template.bind({})}
</Story>
```