enzyme-react-hooks
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

enzyme-react-hooks

React hooks testing utils for Enzyme

NPM MIT License

Easily test react hooks with Enzyme, using enzyme implementation of the renderHook testing util. Based upon React Hooks Testing Library. Inspired by the teachings of Kent C. Dodds in his Epic React Workshop.

Install

npm install --save-dev enzyme-react-hooks

Usage

import { act } from "react-dom/test-utils";
import { renderHook } from "enzyme-react-hooks";
import { useCounter } from "./useCounter";

it("should increment counter", () => {
  const { result } = renderHook(useCounter);

  act(() => result.current.increment());

  expect(result.current.count).toBe(1);
});

Credits

React Hooks Testing Library

Kent C. Dodds' Epic React Workshop

License

MIT © Igor Pavloski

Dependents (0)

Package Sidebar

Install

npm i enzyme-react-hooks

Weekly Downloads

23

Version

1.1.0

License

MIT

Unpacked Size

7.29 kB

Total Files

10

Last publish

Collaborators

  • pavloskii