Since nuqs 2, you can unit-test components that use useQueryState(s) hooks
by wrapping your rendered component in a NuqsTestingAdapter, or using
the withNuqsTestingAdapter higher-order component.
Since nuqs 2 is an ESM-only package,
there are a few hoops you need to jump through to make it work with Jest.
This is extracted from the Jest ESM guide.
Add the following options to your jest.config.ts file:
Change your test command to include the --experimental-vm-modules flag:
The withNuqsTestingAdapter function is a higher-order component that
wraps your component with a NuqsTestingAdapter, but you can also use
it directly.
It takes the following props:
searchParams: The initial search params to use for the test. These can be a
query string, a URLSearchParams object or a record object with string values.