mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-10 00:12:22 +08:00
25 lines
612 B
Plaintext
25 lines
612 B
Plaintext
```ts
|
|
// MyComponent.stories.ts
|
|
|
|
import { fireEvent, screen, userEvent } from '@storybook/testing-library';
|
|
|
|
import { MyComponent } from './MyComponent.component';
|
|
|
|
export default {
|
|
component: MyComponent,
|
|
//👇 Marking the onButtonClick with this configuration will log the event in the Actions panel
|
|
argTypes: { onButtonClick: { action: true } },
|
|
};
|
|
|
|
export const ClickExample = {
|
|
play: async () => {
|
|
await userEvent.click(screen.getByTestId('data-testid'));
|
|
},
|
|
};
|
|
|
|
export const FireEventExample = {
|
|
play: async () => {
|
|
await fireEvent.click(screen.getByTestId('data-testid'));
|
|
},
|
|
};
|
|
``` |