Skip to content

Instantly share code, notes, and snippets.

@alpavlove
Last active August 18, 2022 13:19
Show Gist options
  • Save alpavlove/eaa25e7c7bcccf3bcf97f134a4bfed3f to your computer and use it in GitHub Desktop.
Save alpavlove/eaa25e7c7bcccf3bcf97f134a4bfed3f 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('default', () => {
render(<Button onClick={console.log}>Click me</Button>);
const button = screen.getByText('Click me');
expect(button.classList.contains('button-primary')).toBeTruthy();
});
// test('success', () => {});
// test('disabled', () => {});
// 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