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

21 lines
531 B
Plaintext

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