storybook/docs/snippets/react/my-component-play-function-with-delay.mdx.mdx
jonniebigodes e5fbb02957
Update docs/snippets/react/my-component-play-function-with-delay.mdx.mdx
Co-authored-by: Kyle Gach <kyle.gach@gmail.com>
2021-10-06 17:51:44 +01:00

28 lines
752 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 () => {
await userEvent.type(screen.getByTestId('example-element'), 'random string', {
delay: 100,
});
await userEvent.type(screen.getByTestId('another-example-element'), 'another random string', {
delay: 100,
});
}} />
```