-
Notifications
You must be signed in to change notification settings - Fork 231
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
What is your question:
Consider I have a custom hook that contains a few callbacks
const useDummyHook= ()=>{
const useAysncCallback = useCallback(async(foo:string) =>{
if(foo !== "bar){
throw new Error("foo did not equal bar);
}
})
}I want to test this error throws using renderHook. I cannot get the following to pass:
it('should throw an error if foo does not equal bar', async ()=>{
const { result } = renderHook(()=>useDummyHook())
await expect(async() =>{
result.current.useAysncCallback("notBar")
}).toThrow()
})When I run the test, the test says the given function has not thrown an error, but If i do not assert that an error is thrown the test throws an error.
Am I using the custom hooks wrong? Am I missing something in renderHook?
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested