Skip to content

Commit a40306b

Browse files
committed
Fix flaky test
1 parent 4ba1601 commit a40306b

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/components/Contacts/ContactsLeftPanel/ContactsLeftPanel.test.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useContext, useEffect } from 'react';
22
import { ThemeProvider } from '@emotion/react';
3-
import { render, waitFor } from '@testing-library/react';
3+
import { render } from '@testing-library/react';
44
import userEvent from '@testing-library/user-event';
55
import TestRouter from '__tests__/util/TestRouter';
66
import { GqlMockedProvider } from '__tests__/util/graphqlMocking';
@@ -34,7 +34,6 @@ jest.mock('notistack', () => ({
3434

3535
const userOptions = [
3636
{
37-
id: 'test-id',
3837
key: 'contacts_view',
3938
value: 'map',
4039
},
@@ -78,7 +77,7 @@ describe('ContactsLeftPanel', () => {
7877
return null;
7978
};
8079

81-
const { getByText } = render(
80+
const { findByText } = render(
8281
<ThemeProvider theme={theme}>
8382
<TestRouter router={router}>
8483
<GqlMockedProvider<{ UserOption: UserOptionQuery }> mocks={mocks}>
@@ -93,9 +92,7 @@ describe('ContactsLeftPanel', () => {
9392
</ThemeProvider>,
9493
);
9594

96-
await waitFor(() => expect(getByText('Contact 1')).toBeInTheDocument());
97-
98-
userEvent.click(getByText('Contact 1'));
95+
userEvent.click(await findByText('Contact 1'));
9996
expect(panTo).toHaveBeenCalledWith({ lat: 10, lng: 20 });
10097
});
10198
});

0 commit comments

Comments
 (0)