Skip to main content

TestingProviders

TestingProviders component combines a set of components that provide a context that is needed for testing components and hooks. createContext is used to create a context object. The data that the context object holds is passed to corresponding components, e.g. DataClientProvider component receives client object.

import { TestingProviders } from '@archibald/testing';

<TestingProviders context={CONTEXT} customWrapper={WRAPPER}>
{CHILDREN}
</TestingProviders>;

render and renderHook functions from the Testing Library required the TestingProviders component to be provided in an options object. contextWrapper function is provided to create such an options object.

import { contextWrapper } from '@archibald/testing';

const wrapperOptions = contextWrapper(CONTEXT, HOOK_PROPS, WRAPPER);