You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Multiple component test files duplicate the same render-wrapper pattern: create a QueryClient, wrap the component in QueryClientProvider + jotai Provider + TooltipProvider, seed state via DbState.applyTo(store). This pattern appears at least in SchemaExplorerSidebar.test.tsx, Styles.test.tsx, and others with similar shape.
The seam is: a render function that wraps any component in the standard required context providers, given a DbState to seed. Today every test file re-derives this boilerplate.
Questions to investigate
What is the right abstraction boundary? A renderWithState(component, state) that returns the standard render() result? Or a reusable wrapper-component factory?
Should it compose with the existing renderHookWithState (which already handles the Jotai store + QueryClient for hook tests)? Is there a unified TestProvider that both can share?
Does the vi.mock("react-virtuoso", ...) block (also duplicated across files that render Virtuoso lists) belong in a shared mock utility, or should it stay per-file since mocking has test-file scope?
What about the getAppStore() call — should the helper own creating a fresh store, or should callers still pass one?
Desired outcome
A concrete recommendation (with a sketch) for a @/utils/testing helper that reduces component-test boilerplate without coupling tests to each other. The helper should be opt-in (existing tests don't break if they don't adopt it) and composable with DbState.
Description
Multiple component test files duplicate the same render-wrapper pattern: create a
QueryClient, wrap the component inQueryClientProvider+ jotaiProvider+TooltipProvider, seed state viaDbState.applyTo(store). This pattern appears at least inSchemaExplorerSidebar.test.tsx,Styles.test.tsx, and others with similar shape.The seam is: a render function that wraps any component in the standard required context providers, given a
DbStateto seed. Today every test file re-derives this boilerplate.Questions to investigate
renderWithState(component, state)that returns the standardrender()result? Or a reusable wrapper-component factory?renderHookWithState(which already handles the Jotai store + QueryClient for hook tests)? Is there a unifiedTestProviderthat both can share?vi.mock("react-virtuoso", ...)block (also duplicated across files that render Virtuoso lists) belong in a shared mock utility, or should it stay per-file since mocking has test-file scope?getAppStore()call — should the helper own creating a fresh store, or should callers still pass one?Desired outcome
A concrete recommendation (with a sketch) for a
@/utils/testinghelper that reduces component-test boilerplate without coupling tests to each other. The helper should be opt-in (existing tests don't break if they don't adopt it) and composable withDbState.Related
renderStylesandrenderSidebarare near-identical.renderHookWithStatealready solves the hook-level version of this pattern.Important
Internal only — this issue is maintained by the core team and is not accepting external contributions.