Skip to content

Instantly share code, notes, and snippets.

@mariocsantos
Created January 10, 2021 16:31
Show Gist options
  • Save mariocsantos/53e9909869f6a596b254556af4a1c306 to your computer and use it in GitHub Desktop.
Save mariocsantos/53e9909869f6a596b254556af4a1c306 to your computer and use it in GitHub Desktop.
Favorite foods test with waitFor function.
import React from 'react';
import { render, screen, waitFor } from '@testing-library/react';
import { FavoriteFoodList } from '../FavoriteFoodList';
describe('FavoriteFoodList', () => {
it('should render my favorites food', async () => {
render(<FavoriteFoodList />);
await waitFor(() => expect(screen.getAllByRole('listitem')).toHaveLength(3));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment