storybook/docs/snippets/svelte/component-test-with-testing-library.js.mdx
2021-10-20 15:58:44 +01:00

21 lines
506 B
Plaintext

```js
// Form.test.js
import { render, fireEvent } from '@testing-library/svelte';
import LoginForm from './LoginForm.svelte';
import { InvalidForm } from './LoginForm.stories'; //👈 Our stories imported here.
it('Checks if the form is valid', async () => {
const { getByTestId, getByText } = render(LoginForm, {
props: InvalidForm.args,
});
await fireEvent.click(getByText('Submit'));
const isFormValid = getByTestId('invalid-form');
expect(isFormValid).toBeInTheDocument();
});
```