mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-11 00:06:25 +08:00
34 lines
823 B
Plaintext
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/>',
|
|
})} />
|
|
```
|