/** * 测试包装组件 * 提供测试环境所需的Provider包装 */ import React from 'react'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { BrowserRouter } from 'react-router'; interface TestWrapperProps { children: React.ReactNode; queryClient?: QueryClient; withRouter?: boolean; } const TestWrapper: React.FC = ({ children, queryClient, withRouter = true, }) => { const testQueryClient = queryClient || new QueryClient({ defaultOptions: { queries: { retry: false, gcTime: 0, }, }, }); const content = ( {children} ); if (withRouter) { return {content}; } return content; }; export default TestWrapper;