Skip to content

Instantly share code, notes, and snippets.

@agustinfece
Created January 16, 2021 14:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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