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
Name | Type |
---|---|
Q | extends Queries = typeof queries |
Container | extends Element | DocumentFragment = HTMLElement |
BaseElement | extends 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
Name | Type |
---|---|
«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
Name | Type |
---|---|
Q | extends Queries = __module |
Container | extends Element | DocumentFragment = HTMLElement |
BaseElement | extends Element | DocumentFragment = Container |
Parameters
Name | Type |
---|---|
ui | ReactElement <any , string | JSXElementConstructor <any >> |
options | CustomRenderOptions <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
Name | Type |
---|---|
hook | (initialProps : Props ) => Result |
options | CustomRenderOptions <__module , HTMLElement , HTMLElement > |
Returns
Object
Name | Type | Description |
---|---|---|
rerender | (props? : Props ) => void | Triggers 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.current | Result | The value returned by your renderHook callback |
unmount | () => void | Unmounts 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