storybook/docs/snippets/react/my-component-play-function-with-delay.mdx.mdx
2021-10-08 19:32:55 +01:00

33 lines
863 B
Plaintext

```md
<!-- MyComponent.stories.mdx -->
import { Meta, Story } from '@storybook/addon-docs';
<!-- These are placeholders until the addon-interaction is out -->
import { screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { MyComponent } from './MyComponent.js';
<Meta title="WithDelay" component={MyComponent} />
<!-- The delay option sets the amount of milliseconds between characters being typed-->
<Story
name="DelayedStory"
play={async () => {
const exampleElement= screen.getByLabelText('example-element');
await userEvent.type(exampleElement, 'random string', {
delay: 100,
});
const AnotherExampleElement= screen.getByLabelText('another-example-element');
await userEvent.type(AnotherExampleElement, 'another random string', {
delay: 100,
});
}} />
```