@testing-library/react-hooks#RenderHookOptions TypeScript Examples

The following examples show how to use @testing-library/react-hooks#RenderHookOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: renderHookWithContextSynchronously.tsx    From gatsby-theme-shopify-manager with MIT License 6 votes vote down vote up
// this type signature matches renderHook's type signature
export function renderHookWithContextSynchronously<P, R>(
  callback: (props: P) => R,
  contextOptions?: Partial<ContextOptions>,
  renderHookOptions?: RenderHookOptions<P>,
): RenderHookResult<P, R> {
  return renderHook(callback, {
    ...renderHookOptions,
    wrapper: wrapWithContext(contextOptions),
  });
}
Example #2
Source File: renderHookWithContext.tsx    From gatsby-theme-shopify-manager with MIT License 5 votes vote down vote up
// this type signature matches renderHook's type signature
export async function renderHookWithContext<P, R>(
  callback: (props: P) => R,
  contextOptions?: Partial<ContextOptions>,
  renderHookOptions?: RenderHookOptions<P>,
): Promise<RenderHookResult<P, R>> {
  const hookRender = renderHook(callback, {
    ...renderHookOptions,
    wrapper: wrapWithContext(contextOptions),
  });
  await hookRender.waitForNextUpdate();
  return hookRender;
}