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

26 lines
755 B
Plaintext

```js
// MyComponent.stories.js | MyComponent.stories.jsx | MyComponent.stories.ts | MyComponent.stories.tsx
// 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';
export default {
component: MyComponent,
};
export const DelayedStory = {
play: async () => {
// The delay option sets the amount of milliseconds between characters being typed
await userEvent.type(screen.getByTestId('example-element'), 'random string', {
delay: 100,
});
await userEvent.type(screen.getByTestId('another-example-element'), 'another random string', {
delay: 100,
});
},
};
```