Skip to content

Instantly share code, notes, and snippets.

@darde
Created February 22, 2020 23:25
Show Gist options
  • Save darde/2ec50359339177ed57b60d2a5ecd2e60 to your computer and use it in GitHub Desktop.
Save darde/2ec50359339177ed57b60d2a5ecd2e60 to your computer and use it in GitHub Desktop.
Medium store - Testing asynchronous code with Jest and Testing Library React - src/App.test.js
import React from 'react';
import { render, cleanup } from '@testing-library/react';
import App from './App';
describe('App', () => {
describe('when the fetch operation is pending', () => {
it('shows a loading span', () => {
const { getByText } = render(<App />);
expect(getByText(/loading/i)).toBeInTheDocument();
cleanup();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment