Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@testing-library/react-hooks

Package Overview
Dependencies
Maintainers
16
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@testing-library/react-hooks - npm Package Compare versions

Comparing version 5.0.0-beta.5 to 5.0.0-beta.6

4

lib/core/index.d.ts

@@ -1,4 +0,4 @@

import { CreateRenderer, Renderer, RenderHook, RenderHookOptions } from '../types';
import { CreateRenderer, Renderer, RenderHook } from '../types';
import { cleanup, addCleanup, removeCleanup } from './cleanup';
declare function createRenderHook<TProps, TResult, TOptions extends {}, TRenderer extends Renderer<TProps>>(createRenderer: CreateRenderer<TProps, TResult, TOptions, TRenderer>): (callback: (props: TProps) => TResult, options?: RenderHookOptions<TProps, TOptions>) => RenderHook<TProps, TResult, TRenderer>;
declare function createRenderHook<TProps, TResult, TOptions extends object, TRenderer extends Renderer<TProps>>(createRenderer: CreateRenderer<TProps, TResult, TOptions, TRenderer>): RenderHook<TProps, TResult, TOptions>;
export { createRenderHook, cleanup, addCleanup, removeCleanup };
import { act } from 'react-dom/test-utils';
import { RendererOptions } from '../types/react';
import { cleanup, addCleanup, removeCleanup } from '../core';
declare const renderHook: <TProps, TResult>(callback: (props: TProps) => TResult, options?: import("../types").RenderHookOptions<TProps, RendererOptions<TProps>>) => import("../types").RenderHook<TProps, TResult, {
render(props?: TProps | undefined): void;
rerender(props?: TProps | undefined): void;
unmount(): void;
act: typeof act;
}>;
declare const renderHook: <TProps, TResult>(callback: (props: TProps) => TResult, options?: import("../types").RenderHookOptions<TProps, RendererOptions<TProps>> | undefined) => import("../types").RenderHookResult<TProps, TResult, import("../types").Renderer<TProps>>;
export { renderHook, act, cleanup, addCleanup, removeCleanup };
export * from '../types';
export * from '../types/react';
import { act } from 'react-test-renderer';
import { RendererOptions } from '../types/react';
import { cleanup, addCleanup, removeCleanup } from '../core';
declare const renderHook: <TProps, TResult>(callback: (props: TProps) => TResult, options?: import("../types").RenderHookOptions<TProps, RendererOptions<TProps>>) => import("../types").RenderHook<TProps, TResult, {
render(props?: TProps | undefined): void;
rerender(props?: TProps | undefined): void;
unmount(): void;
act: typeof act;
}>;
declare const renderHook: <TProps, TResult>(callback: (props: TProps) => TResult, options?: import("../types").RenderHookOptions<TProps, RendererOptions<TProps>> | undefined) => import("../types").RenderHookResult<TProps, TResult, import("../types").Renderer<TProps>>;
export { renderHook, act, cleanup, addCleanup, removeCleanup };
export * from '../types';
export * from '../types/react';

@@ -1,4 +0,4 @@

declare const renderHook: <TProps, TResult>(callback: (props: TProps) => TResult, options?: import("./types").RenderHookOptions<TProps, import("./types/react").RendererOptions<TProps>> | undefined) => import("./types").RenderHook<TProps, TResult, import("./types").Renderer<TProps>>, act: import("./types").Act, cleanup: () => void, addCleanup: (callback: () => void | Promise<void>) => () => void, removeCleanup: (callback: () => void | Promise<void>) => void;
declare const renderHook: <TProps, TResult>(callback: (props: TProps) => TResult, options?: import("./types").RenderHookOptions<TProps, import("./types/react").RendererOptions<TProps>> | undefined) => import("./types").RenderHookResult<TProps, TResult, import("./types").Renderer<TProps>>, act: import("./types").Act, cleanup: () => void, addCleanup: (callback: () => void | Promise<void>) => () => void, removeCleanup: (callback: () => void | Promise<void>) => void;
export { renderHook, act, cleanup, addCleanup, removeCleanup };
export * from './types';
export * from './types/react';
import { act } from 'react-dom/test-utils';
import { RendererOptions } from '../types/react';
import { cleanup, addCleanup, removeCleanup } from '../core';
declare const renderHook: <TProps, TResult>(callback: (props: TProps) => TResult, options?: import("../types").RenderHookOptions<TProps, RendererOptions<TProps>>) => import("../types").RenderHook<TProps, TResult, {
render(props?: TProps | undefined): void;
hydrate(): void;
rerender(props?: TProps | undefined): void;
unmount(): void;
act: typeof act;
}>;
declare const renderHook: <TProps, TResult>(callback: (props: TProps) => TResult, options?: import("../types").RenderHookOptions<TProps, RendererOptions<TProps>> | undefined) => import("../types").RenderHookResult<TProps, TResult, import("../types").Renderer<TProps>>;
export { renderHook, act, cleanup, addCleanup, removeCleanup };
export * from '../types';
export * from '../types/react';

@@ -31,6 +31,9 @@ export declare type Renderer<TProps> = {

};
export declare type RenderHook<TProps, TValue, TRenderer extends Renderer<TProps> = Renderer<TProps>> = ResultContainer<TValue> & Omit<Renderer<TProps>, 'render' | 'act'> & Omit<TRenderer, keyof Renderer<TProps>> & AsyncUtils;
export declare type RenderHookOptions<TProps, TOptions extends {}> = TOptions & {
export declare type RenderHookResult<TProps, TValue, TRenderer extends Renderer<TProps> = Renderer<TProps>> = ResultContainer<TValue> & Omit<Renderer<TProps>, 'render' | 'act'> & Omit<TRenderer, keyof Renderer<TProps>> & AsyncUtils;
export declare type RenderHookOptions<TProps, TOptions extends object> = TOptions & {
initialProps?: TProps;
};
export interface RenderHook<TProps, TResult, TOptions extends object> {
(callback: (props: TProps) => TResult, options?: RenderHookOptions<TProps, TOptions>): RenderHookResult<TProps, TResult>;
}
export interface Act {

@@ -37,0 +40,0 @@ (callback: () => void | undefined): void;

import { ComponentType } from 'react';
import { RenderHook, RenderHookOptions, Act } from '.';
import { RenderHookOptions, RenderHookResult, Act } from '.';
export declare type WrapperComponent<TProps> = ComponentType<TProps>;

@@ -7,4 +7,4 @@ export declare type RendererOptions<TProps> = {

};
export interface ReactHooksRenderer {
renderHook: <TProps, TResult>(callback: (props: TProps) => TResult, options?: RenderHookOptions<TProps, RendererOptions<TProps>>) => RenderHook<TProps, TResult>;
export declare type ReactHooksRenderer = {
renderHook: <TProps, TResult>(callback: (props: TProps) => TResult, options?: RenderHookOptions<TProps, RendererOptions<TProps>>) => RenderHookResult<TProps, TResult>;
act: Act;

@@ -14,2 +14,2 @@ cleanup: () => void;

removeCleanup: (callback: () => Promise<void> | void) => void;
}
};
{
"name": "@testing-library/react-hooks",
"version": "5.0.0-beta.5",
"version": "5.0.0-beta.6",
"description": "Simple and complete React hooks testing utilities that encourage good testing practices.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -43,9 +43,14 @@ import { CreateRenderer, Renderer, RenderResult, RenderHook, RenderHookOptions } from '../types'

function createRenderHook<TProps, TResult, TOptions extends {}, TRenderer extends Renderer<TProps>>(
function createRenderHook<
TProps,
TResult,
TOptions extends object,
TRenderer extends Renderer<TProps>
>(
createRenderer: CreateRenderer<TProps, TResult, TOptions, TRenderer>
) {
const renderHook = (
callback: (props: TProps) => TResult,
options: RenderHookOptions<TProps, TOptions> = {} as RenderHookOptions<TProps, TOptions>
): RenderHook<TProps, TResult, TRenderer> => {
): RenderHook<TProps, TResult, TOptions> {
const renderHook: RenderHook<TProps, TResult, TOptions> = (
callback,
options = {} as RenderHookOptions<TProps, TOptions>
) => {
const { result, setValue, setError, addResolver } = resultContainer<TResult>()

@@ -85,3 +90,2 @@ const renderProps = { callback, setValue, setError }

return renderHook

@@ -88,0 +92,0 @@ }

@@ -41,3 +41,3 @@ export type Renderer<TProps> = {

export type RenderHook<
export type RenderHookResult<
TProps,

@@ -51,6 +51,13 @@ TValue,

export type RenderHookOptions<TProps, TOptions extends {}> = TOptions & {
export type RenderHookOptions<TProps, TOptions extends object> = TOptions & {
initialProps?: TProps
}
export interface RenderHook<TProps, TResult, TOptions extends object> {
(
callback: (props: TProps) => TResult,
options?: RenderHookOptions<TProps, TOptions>
): RenderHookResult<TProps, TResult>
}
export interface Act {

@@ -57,0 +64,0 @@ (callback: () => void | undefined): void

import { ComponentType } from 'react'
import { RenderHook, RenderHookOptions, Act } from '.'
import { RenderHookOptions, RenderHookResult, Act } from '.'

@@ -11,7 +11,7 @@ export type WrapperComponent<TProps> = ComponentType<TProps>

export interface ReactHooksRenderer {
export type ReactHooksRenderer = {
renderHook: <TProps, TResult>(
callback: (props: TProps) => TResult,
options?: RenderHookOptions<TProps, RendererOptions<TProps>>
) => RenderHook<TProps, TResult>
) => RenderHookResult<TProps, TResult>
act: Act

@@ -18,0 +18,0 @@ cleanup: () => void

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc