showing results for - "react testing library for hooks"
Violeta
13 Jul 2019
1import { renderHook, act } from '@testing-library/react-hooks'
2import useCounter from './useCounter'
3
4test('should increment counter', () => {
5  const { result } = renderHook(() => useCounter())
6
7  act(() => {
8    result.current.increment()
9  })
10
11  expect(result.current.count).toBe(1)
12})
Maelyne
25 Apr 2018
1npm install --save-dev @testing-library/react-hooks
Diego Alejandro
06 Jul 2016
1import { useState, useCallback } from 'react'
2
3function useCounter() {
4  const [count, setCount] = useState(0)
5
6  const increment = useCallback(() => setCount((x) => x + 1), [])
7
8  return { count, increment }
9}
10
11export default useCounter
queries leading to this page
install react hooks testing libraryreact testing library hooksnpm testing library 2freact hooksreact testing lib hooksreact testing library usestatereact testing library hooks actnpm 40testing library 2freact hooksreact testing library with hookshooks testingreact testing library react hookscalling hooks 22react testing library 22react hooks testing libraryhow to test hooks in react testing librarytest hook react testing library react hooks testing libararytesting react hooks with react testing libraryreact testing library tutorial hooks searchhow to write hooks test using react testing libraryreact hook testing librarytesting hooks with react testing libraryreact testing library usestatetesting library reacttesting hooks react testing libraryreact testing library how to test hookreact hooks and testingreack hooks testing libraryreact hook testingreact testing library using hooksreact testing library usestate hookreact hooks testing library npmcall 3ding hooks react testing libraryreact testing library with react hookstesting custom hooks react testing libraryhook testing librarytest react hookstesting library hookdtesting library test react hookstesting react hooksreact testing library hookreact testing library test hooksreact testing labrary hooksg react testing library hookrender hooks testing librarytesting library custom hookstesting library react hooks dependeciesreact hooks testing libraryhow good in react testing libraryreact hooks testing libreact testing library custom hookhow to test hook in react testing librarytesting library tset hookreact testing library how to test hooksreacting testing library hookstest hooks react testing library 40testing library 2freact hooks npmtesting react hooks with react testing libraryreact testing library test custom hookstesting library react hooksrenderhook react testing librarytesting library hookshow to test hooks using react testing librarycalling hooks react testing libraryreact testing library hookstesting with react hooks testing librarytesting library react hooksreact testing hooks componentshow to test react hooks react testing libraryreact testing library hook testreact testing library call hooksnpm react hooks testing libraryreact testing library for hooksreact testing librart hook 40testing library 2freact hooks acttesting hokos 40testing library 2freact hookstesting library 2freact hooks npmbest react testing libraryreact testing library hooks examplerender hook testing libraryhow to use hook react testing libraryreact testing librart renderhookreact test hookstesting hooksreact testing library custom hooksreact testing librarytesting react hooks react testing librarytest react hooks with jest testing libraryreact testing libary react hookstesting library react hooks examplereact testing library for hooks