Skip to content

Spike: extract a shared component-render test helper to reduce test harness duplication #1917

Description

@kmcginnes

Description

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.

Related

Important

Internal only — this issue is maintained by the core team and is not accepting external contributions.

Metadata

Metadata

Assignees

Labels

internalSignals that the team will work on this issue internally.tech debtIssues, typically tasks, that are mainly about cleaning up code that is problematic in some way

Type

Fields

No fields configured for Spike.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions