Skip to main content

Module: tests/utils/rendering

Type Aliases

CoreTestProvidersProps

Ƭ CoreTestProvidersProps: PropsWithChildren<{ intlLocale: Locale ; intlMessages: TranslationMessages ; routerProps: MemoryRouterProps }>

A set of properties that are passed to CoreTestProviders component to override the initial state of providers

Defined in

packages/webapp-libs/webapp-core/src/tests/utils/rendering.tsx:16


CustomRenderOptions

Ƭ CustomRenderOptions<Q, Container, BaseElement>: RenderOptions<Q, Container, BaseElement> & WrapperProps

Type parameters

NameType
Qextends Queries = typeof queries
Containerextends Element | DocumentFragment = HTMLElement
BaseElementextends Element | DocumentFragment = Container

Defined in

packages/webapp-libs/webapp-core/src/tests/utils/rendering.tsx:82


WrapperProps

Ƭ WrapperProps: Partial<CoreTestProvidersProps>

Defined in

packages/webapp-libs/webapp-core/src/tests/utils/rendering.tsx:54

Functions

CoreTestProviders

CoreTestProviders(«destructured»): Element

Component that renders a set of providers used in tests globally like: MemoryRouter, LocalesProvider, ToastProvider, IntlProvider, etc...

It is used in render and renderHook methods.

Parameters

NameType
«destructured»CoreTestProvidersProps

Returns

Element

Defined in

packages/webapp-libs/webapp-core/src/tests/utils/rendering.tsx:33


render

render<Q, Container, BaseElement>(ui, options?): RenderResult<Q, Container, BaseElement>

Method that extends render method from @testing-library/react package. It composes a wrapper using CoreTestProviders component and options property that is passed down to parent render method.

Type parameters

NameType
Qextends Queries = __module
Containerextends Element | DocumentFragment = HTMLElement
BaseElementextends Element | DocumentFragment = Container

Parameters

NameType
uiReactElement<any, string | JSXElementConstructor<any>>
optionsCustomRenderOptions<Q, Container, BaseElement>

Returns

RenderResult<Q, Container, BaseElement>

Defined in

packages/webapp-libs/webapp-core/src/tests/utils/rendering.tsx:95


renderHook

renderHook<Result, Props>(hook, options?): Object

Method that extends renderHook method from @testing-library/react package. It composes a wrapper using CoreTestProviders component and options property that is passed down to parent renderHook method.

Type parameters

Name
Result
Props

Parameters

NameType
hook(initialProps: Props) => Result
optionsCustomRenderOptions<__module, HTMLElement, HTMLElement>

Returns

Object

NameTypeDescription
rerender(props?: Props) => voidTriggers a re-render. The props will be passed to your renderHook callback.
result{ current: Result }This is a stable reference to the latest value returned by your renderHook callback
result.currentResultThe value returned by your renderHook callback
unmount() => voidUnmounts the test component. This is useful for when you need to test any cleanup your useEffects have.

Defined in

packages/webapp-libs/webapp-core/src/tests/utils/rendering.tsx:120