Files
mygit/apps/admin/test-utils/test-helpers.ts
T
DuckQ1u 93d1b7c3d3
Copilot Setup Steps / copilot-setup-steps (push) Has been cancelled
first commit
2026-04-22 19:51:20 +07:00

14 lines
539 B
TypeScript

import { waitFor } from "@testing-library/react";
import { expect } from "vitest";
import type { UseQueryResult } from "@tanstack/react-query";
export async function waitForQuerySettled<T>(result: { current: UseQueryResult<T, unknown> }) {
await waitFor(
() => {
// Query is settled when it has reached a terminal state (success or error)
const isSettled = (result.current.isSuccess || result.current.isError) && !result.current.isFetching;
expect(isSettled).toBe(true);
}
);
}