Skip to content

Commit

Permalink
Refactor waitForLoadingToFinish function to include a timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
luismarques-io committed Jan 21, 2024
1 parent d455f83 commit c98c1d8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/test/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ export const createComment = async (properties?: any) => {
export const waitForLoadingToFinish = async () => {
const tmpLoadingElements = [...screen.queryAllByTestId(/loading/i), ...screen.queryAllByText(/loading/i)];
if (tmpLoadingElements.length > 0) {
await waitFor(async () => {
await waitForElementToBeRemoved(() => [
...screen.queryAllByTestId(/loading/i),
...screen.queryAllByText(/loading/i),
]);
});
await waitFor(
async () => {
await waitForElementToBeRemoved(() => [
...screen.queryAllByTestId(/loading/i),
...screen.queryAllByText(/loading/i),
]);
},
{ timeout: 10000 }
);
}
};

Expand Down

0 comments on commit c98c1d8

Please sign in to comment.