Skip to content

Instantly share code, notes, and snippets.

@agustinfece
Created January 16, 2021 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agustinfece/e8d994f9362299cd8a538ddb3eda204e to your computer and use it in GitHub Desktop.
Save agustinfece/e8d994f9362299cd8a538ddb3eda204e to your computer and use it in GitHub Desktop.
App2.test.js
import { render, screen, fireEvent } from '@testing-library/react';
import App from './App';
test('changes application state', () => {
render(<App />);
const buttonElement = screen.getByRole('button');
expect(buttonElement).toBeInTheDocument();
expect(screen.queryByText('Click the button')).toBeInTheDocument();
expect(screen.queryByText('Pressed!')).toBeNull();
fireEvent.click(buttonElement);
expect(screen.queryByText('Click the button')).toBeNull();
expect(screen.queryByText('Pressed!')).toBeInTheDocument();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment