Skip to content

Instantly share code, notes, and snippets.

@alpavlove
Created August 18, 2022 13:29
Show Gist options
  • Save alpavlove/c2dc7c5dc8f7e2c9631b1c30a6875f74 to your computer and use it in GitHub Desktop.
Save alpavlove/c2dc7c5dc8f7e2c9631b1c30a6875f74 to your computer and use it in GitHub Desktop.
Test React Components library
import React from 'react';
import { render, screen } from '@testing-library/react';
import { Button } from '../src/Button/Button';
describe('Button', () => {
describe('Should be rendered correctly', () => {
test('disabled', () => {
const { asFragment } = render(
<Button onClick={console.log} isDisabled={true}>
Click me
</Button>
);
expect(asFragment()).toMatchInlineSnapshot();
});
// test('should be clickable', () => {});
// test('should not be clickable if disabled', () => {});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment