Path: blob/main/components/dashboard/src/contexts/TestContext.tsx
2500 views
/**1* Copyright (c) 2023 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56import { QueryClient, QueryClientProvider } from "@tanstack/react-query";7import { render } from "@testing-library/react";8import { FC } from "react";910// Add necessary contexts for tests to run11export const TestContext: FC = ({ children }) => {12const queryClient = new QueryClient({13defaultOptions: {14queries: {15retry: false,16},17},18});1920return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>;21};2223type RenderParameters = Parameters<typeof render>;24type RenderReturn = ReturnType<typeof render>;2526// render() with <TestContext> wrapper27export const renderWithContext = (ui: RenderParameters["0"], options?: RenderParameters["1"]): RenderReturn => {28return render(<TestContext>{ui}</TestContext>, options);29};303132