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
| Parameter | Type | Description |
|---|---|---|
children | ReactNode | The React tree to be wrapped. |
container | Container | An 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));