fbredius/storybook

View on GitHub
docs/snippets/svelte/register-component-with-play-function.mdx.mdx

Summary

Maintainability
Test Coverage
```md
<!-- RegistrationForm.stories.mdx -->

import { Meta, Story } from '@storybook/addon-docs';

import { screen, userEvent } from '@storybook/testing-library';

import RegistrationForm from './RegistrationForm.svelte';

<Meta title="RegistrationForm" component={RegistrationForm} />

export const Template = (args) => ({
  Component: RegistrationForm,
  props: args,
});

<Story
  name="FilledForm"
  play={async () => {
    const emailInput = screen.getByLabelText('email', {
      selector: 'input',
    });
    await userEvent.type(emailInput, 'example-email@email.com', {
      delay: 100,
    });

    const passwordInput = screen.getByLabelText('password', {
      selector: 'input',
    });

    await userEvent.type(passwordInput, 'ExamplePassword', {
      delay: 100,
    });
    // See https://storybook.js.org/docs/svelte/essentials/actions#automatically-matching-args to learn how to setup logging in the Actions panel
    const submitButton = screen.getByRole('button');
    await userEvent.click(submitButton);
  }}>
  {Template.bind({})}
</Story>
```