mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 07:01:53 +08:00
29 lines
759 B
Plaintext
29 lines
759 B
Plaintext
```js
|
|
// MyComponent.stories.js
|
|
|
|
import { userEvent, within } from '@storybook/test';
|
|
|
|
export default = {
|
|
component: 'my-component',
|
|
};
|
|
|
|
/*
|
|
* See https://storybook.js.org/docs/writing-stories/play-function#working-with-the-canvas
|
|
* to learn more about using the canvasElement to query the DOM
|
|
*/
|
|
export const Submitted = {
|
|
play: async ({ args, canvasElement, step }) => {
|
|
const canvas = within(canvasElement);
|
|
|
|
await step('Enter email and password', async () => {
|
|
await userEvent.type(canvas.getByTestId('email'), 'hi@example.com');
|
|
await userEvent.type(canvas.getByTestId('password'), 'supersecret');
|
|
});
|
|
|
|
await step('Submit form', async () => {
|
|
await userEvent.click(canvas.getByRole('button'));
|
|
});
|
|
},
|
|
};
|
|
```
|