-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathtest-utils.tsx
More file actions
39 lines (33 loc) · 1.2 KB
/
test-utils.tsx
File metadata and controls
39 lines (33 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React from "react";
import { render, RenderOptions } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "react-query";
import { QueryParamProvider } from "use-query-params";
import { ReactRouter6Adapter } from "use-query-params/adapters/react-router-6";
import { MemoryRouter as Router } from "react-router-dom";
interface ProvidersProps {
children: React.ReactNode;
}
const queryClient = new QueryClient();
const AllTheProviders = ({ children }: ProvidersProps) => {
return (
<QueryClientProvider client={queryClient}>
<Router
// Disable v7_relativeSplatPath: custom tab routes don't currently work with it
future={{ v7_relativeSplatPath: false, v7_startTransition: true }}
initialEntries={["/"]}
>
<QueryParamProvider adapter={ReactRouter6Adapter}>
{children}
</QueryParamProvider>
</Router>
</QueryClientProvider>
);
};
const customRender = (
ui: React.ReactElement,
options?: Omit<RenderOptions, "wrapper">,
) => render(ui, { wrapper: AllTheProviders, ...options });
// re-export everything
export * from "@testing-library/react";
// override render method
export { customRender as render };