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

32 lines
773 B
Plaintext

```js
// MyComponent.stories.js
import { screen, userEvent } from '@storybook/testing-library';
import MyComponent from './MyComponent.vue';
export default {
component: MyComponent,
};
export const DelayedStory = {
play: async () => {
const exampleElement= screen.getByLabelText('example-element');
// The delay option set the ammount of milliseconds between characters being typed
await userEvent.type(exampleElement, 'random string', {
delay: 100,
});
const AnotherExampleElement= screen.getByLabelText('another-example-element');
await userEvent.type(AnotherExampleElement, 'another random string', {
delay: 100,
});
},
render: () => ({
components: { MyComponent },
template: '<MyComponent />',
}),
};
```