Skip to content

Instantly share code, notes, and snippets.

@agustinfece
Created Jan 16, 2021
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