Answers for "testing library react hooks"

0

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)
})
Posted by: Guest on November-28-2020
0

react testing library for hooks

npm install --save-dev @testing-library/react-hooks
Posted by: Guest on April-13-2021
0

react testing library for hooks

import { useState, useCallback } from 'react'

function useCounter() {
  const [count, setCount] = useState(0)

  const increment = useCallback(() => setCount((x) => x + 1), [])

  return { count, increment }
}

export default useCounter
Posted by: Guest on April-13-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language