Skip to content

Commit 1ab1ad9

Browse files
SannidhyaSannidhya
authored andcommitted
fix: Add QueryClientProvider to test utils for React Query support
1 parent c9f74e2 commit 1ab1ad9

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

webview-ui/src/utils/test-utils.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from "react"
22
import { render, RenderOptions } from "@testing-library/react"
3+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
34

45
import { TooltipProvider } from "@src/components/ui/tooltip"
56
import { STANDARD_TOOLTIP_DELAY } from "@src/components/ui/standard-tooltip"
@@ -9,7 +10,20 @@ interface AllTheProvidersProps {
910
}
1011

1112
const AllTheProviders = ({ children }: AllTheProvidersProps) => {
12-
return <TooltipProvider delayDuration={STANDARD_TOOLTIP_DELAY}>{children}</TooltipProvider>
13+
// Create a new QueryClient for each test to avoid state leakage
14+
const queryClient = new QueryClient({
15+
defaultOptions: {
16+
queries: {
17+
retry: false, // Disable retries in tests
18+
},
19+
},
20+
})
21+
22+
return (
23+
<QueryClientProvider client={queryClient}>
24+
<TooltipProvider delayDuration={STANDARD_TOOLTIP_DELAY}>{children}</TooltipProvider>
25+
</QueryClientProvider>
26+
)
1327
}
1428

1529
const customRender = (ui: React.ReactElement, options?: Omit<RenderOptions, "wrapper">) =>

0 commit comments

Comments
 (0)