Skip to content

Instantly share code, notes, and snippets.

@ahayes91
Last active June 12, 2021 20:47
Show Gist options
  • Save ahayes91/55e15c587c9f84301855efc00420df85 to your computer and use it in GitHub Desktop.
Save ahayes91/55e15c587c9f84301855efc00420df85 to your computer and use it in GitHub Desktop.
Starter file needed for an app-level integration test.
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import getAndSetupServer from './getAndSetupServer';
import App from './App';
getAndSetupServer();
describe('Posts app: ', () => {
test('renders button and mocked post in a table on button click', async () => {
render(<App />);
const button = screen.getByRole('button', { name: 'Click me to fetch posts!' } );
expect(button).toBeInTheDocument();
userEvent.click(button);
await screen.findByRole('columnheader', { name: 'Title'});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment