Skip to content

Instantly share code, notes, and snippets.

@manoj-mass
Created July 6, 2021 06:00
Show Gist options
  • Save manoj-mass/86d71c5f8c3d64a6d805f0e572d5421f to your computer and use it in GitHub Desktop.
Save manoj-mass/86d71c5f8c3d64a6d805f0e572d5421f to your computer and use it in GitHub Desktop.
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Counter from './Counter';
const setUp = () => render(<Counter />);
beforeEach(() => {
setUp()
})
describe('test counter app', () => {
it('check h1 available', () => {
const linkElement = screen.getByText(/Current count is/i);
expect(linkElement).toBeInTheDocument();
});
it('check button available', () => {
const linkElement = screen.getByText(/Increment/i);
expect(linkElement).toBeInTheDocument();
});
it('check increment', () => {
userEvent.click(screen.getByText(/Increment/i));
const lable = screen.getByTestId(/counterID/i);
expect(lable.textContent).toBe("1");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment