Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

testing library react hooks

import { renderHook, act } from '@testing-library/react-hooks'
import useCounter from './useCounter'

test('should increment counter', () => {
  const { result } = renderHook(() => useCounter())

  act(() => {
    result.current.increment()
  })

  expect(result.current.count).toBe(1)
})
Source by github.com #
 
PREVIOUS NEXT
Tagged: #testing #library #react #hooks
ADD COMMENT
Topic
Name
1+5 =