Skip to content

Function: withContainerProvider()

ts
function withContainerProvider(children: ReactNode, container?: Container): FunctionComponentElement<ContainerProviderProps>;

Defined in: src/wirestate-react/test-utils/with-container-provider.ts:27

Wraps a React element tree with ContainerProvider for testing purposes.

Parameters

ParameterTypeDescription
childrenReactNodeThe React tree to be wrapped.
containerContainerAn optional Inversify container. Defaults to a new mockContainer.

Returns

FunctionComponentElement<ContainerProviderProps>

A React element wrapped in an ContainerProvider.

Remarks

This utility simplifies setting up the IoC context in unit tests. It automatically creates a mockContainer if none is provided.

Example

tsx
const container: Container = mockContainer();

render(withContainerProvider(<MyComponent />, container));