Skip to content

Commit 4e7736b

Browse files
committed
fix: flaky test
1 parent ae057e1 commit 4e7736b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/webapp/__tests__/MostUpvotedPage.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ function renderComponent(
6060

6161
mocks.forEach(mockGraphQL);
6262
nock('http://localhost:3000').get('/v1/a').reply(200, [ad]);
63+
nock('http://localhost:3000')
64+
.post('/graphql')
65+
.reply(200, { data: null })
66+
.persist();
6367

6468
return render(
6569
<TestBootProvider client={client} auth={{ user: resolvedUser }}>
@@ -78,9 +82,8 @@ it('should request most upvoted feed when logged-in', async () => {
7882
version: 15,
7983
}),
8084
]);
81-
await waitFor(async () => {
82-
const elements = await screen.findAllByTestId('postItem');
83-
expect(elements.length).toBeTruthy();
85+
await waitFor(() => {
86+
expect(screen.getAllByTestId('postItem').length).toBeTruthy();
8487
});
8588
});
8689

@@ -97,8 +100,7 @@ it('should request most upvoted feed when not', async () => {
97100
],
98101
undefined,
99102
);
100-
await waitFor(async () => {
101-
const elements = await screen.findAllByTestId('postItem');
102-
expect(elements.length).toBeTruthy();
103+
await waitFor(() => {
104+
expect(screen.getAllByTestId('postItem').length).toBeTruthy();
103105
});
104106
});

0 commit comments

Comments
 (0)