import { renderHook, act } from '@testing-library/react-hooks'
import useRefWithSetter from '../useRefWithSetter'
describe('Test useRefWithSetter', () => {
const { result } = renderHook(() => useRefWithSetter(1))
const [valueRef, setValue] = result.current
test('you can return value through setter function', () => {
act(() => {
setValue(2)
})
expect(valueRef.current).toBe(2)
})
test('you can return callback function through setter function', async () => {
await act(async () => {
setValue((prev) => prev + 3)
return Promise.resolve()
})
expect(valueRef.current).toBe(5)
})
})
Error message : [eslint @typescript-eslint/no-floating-promises] [E] Promises must be handled appropiately or explicitly marked as ignored the void operator. (@typescript-eslint/no-floating-promises)
Hello.
I'm trying to test my customized hook but I don't know how to use 'act' function from react-hooks-testing-library. It shows lint error so I was trying to fix like second test but I don't think it's appropriate way because that hook is not Promise function. Is there any way to explicitly mark as ignored with the void operator?