Document that testing hooks that rely on useQueryState
should use the wrapper option
#794
-
I spent a while trying to figure out how to smoothly test my hook that relies on To test hooks, one uses // hook
const useHook = () => {
const [a, setA] = useState("")
return { a, setA }
}
// test code
const { result } = renderHook(() => useHook())
const { a, setA } = result.current But it fails to do it this simply when using This can be done very simply, however, as follows: // hook
const useHook = () => {
const [a, setA] = useQueryState("a")
return { a, setA }
}
// test code
const { result } = renderHook(() => useHook(), { wrapper: NuqsTestingAdapter })
const { a, setA } = result.current This should be very neatly documentet here: https://nuqs.47ng.com/docs/testing |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
It is in the docs, where we explain that https://nuqs.47ng.com/docs/testing#nuqstestingadapter Maybe that part of the docs can be made more explicit, would you like to open a PR? |
Beta Was this translation helpful? Give feedback.
Added in #795, thanks!
FYI, I renamed the description to "See #784" as semantic-release doesn't support closing keywords for discussions, and crashes when trying to close them as issues (something I need to address at some point).