mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 03:21:49 +08:00
37 lines
963 B
Plaintext
37 lines
963 B
Plaintext
```js
|
|
// MyComponent.stories.js
|
|
|
|
import { screen, userEvent, waitFor } from '@storybook/testing-library';
|
|
|
|
import MyComponent from './MyComponent.vue';
|
|
|
|
export default {
|
|
component: MyComponent,
|
|
};
|
|
|
|
export const ExampleAsyncStory = {
|
|
play: async () => {
|
|
const exampleElement = screen.getByLabelText('example-element', {
|
|
selector: 'input',
|
|
});
|
|
|
|
// The delay option set the ammount of milliseconds between characters being typed
|
|
await userEvent.type(exampleElement, 'WrongInput', {
|
|
delay: 100,
|
|
});
|
|
|
|
// See https://storybook.js.org/docs/7.0/vue/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
|
|
|
|
const Submit = screen.getByRole('button');
|
|
await userEvent.click(Submit);
|
|
|
|
await waitFor(async () => {
|
|
await userEvent.hover(screen.getByTestId('error'));
|
|
});
|
|
},
|
|
render: () => ({
|
|
components: { MyComponent },
|
|
template: '<MyComponent />',
|
|
}),
|
|
};
|
|
``` |