react-hook-testing
v0.0.1
Published
useReducer with effects, the elmish way
Downloads
2
Readme
react-hook-testing
react hook testing
Getting started
npm i react-test-renderer -D
npm i react-hook-testing -D
Description
Minimal version of renderHook
function from @testing-library/react
.
Example
import { useState } from 'react'
import { act } from 'react-test-renderer'
import { renderHook } from 'react-hook-testing'
describe('renderHook', () => {
test('should handle useState', async () => {
// !!! requires await
const { result } = await renderHook(() => useState(1))
expect(result.current[0]).toEqual(1)
await act(() => {
result.current[1](2)
})
expect(result.current[0]).toEqual(2)
})
})