Skip to content

Instantly share code, notes, and snippets.

@alpavlove
Created August 18, 2022 13:20
Show Gist options
  • Save alpavlove/ae46ae2d43ef62d502cdfba75f19ddcd to your computer and use it in GitHub Desktop.
Save alpavlove/ae46ae2d43ef62d502cdfba75f19ddcd 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('success', () => {
const { container } = render(
<Button onClick={console.log} variant="success">
Click me
</Button>
);
const button = container.querySelector('button');
expect(button!.classList.contains('button-success')).toBeTruthy();
});
// 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