storybook/docs/snippets/vue/my-component-play-function-alt-queries.mdx.mdx
2021-10-14 17:15:03 +01:00

34 lines
823 B
Plaintext

```md
<!-- MyComponent.stories.mdx -->
import { Meta, Story } from '@storybook/addon-docs';
import { screen, userEvent } from '@storybook/testing-library';
import MyComponent from './MyComponent.vue';
<!-- 👇 Marking the onButtonClick with this configuration will log the event in the Actions panel -->
<Meta title="QueryMethods" component={MyComponent} argTypes={{ onButtonClick: { action: true }}/>
<Story
name="ExampleWithRole"
play={async () => {
await userEvent.click(screen.getByRole('button'));
}}
render={() => ({
components: { MyComponent },
template: '<MyComponent/>',
})} />
<Story
name="ExampleWithText"
play={async () => {
await screen.findByText('example string');
}}
render={() => ({
components: { MyComponent },
template: '<MyComponent/>',
})} />
```