-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UI v2] feat: Centralizes createWrapper for tests (#16323)
- Loading branch information
1 parent
e569cc5
commit 6aaf035
Showing
9 changed files
with
169 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
import { createElement } from "react"; | ||
export { server } from "./node"; | ||
|
||
/* Wraps render() components with app-wide providers | ||
* | ||
* @example | ||
* import { createWrapper } from '@tests/utils' | ||
* | ||
* ```tsx | ||
* const result = render(<MyComponentToTest />, { | ||
* wrapper: createWrapper(), | ||
* }); | ||
* ``` | ||
*/ | ||
export const createWrapper = ({ queryClient = new QueryClient() } = {}) => { | ||
// Written with createElement because our current vite config doesn't support jsx in tests/ | ||
const Wrapper = ({ children }: { children: React.ReactNode }) => | ||
createElement(QueryClientProvider, { client: queryClient }, children); | ||
return Wrapper; | ||
}; |
File renamed without changes.
Oops, something went wrong.