Description
Context
What's your version of nuqs
?
"nuqs": "^2.4.1",
What framework are you using?
- ✅ Next.js (app router)
Which version of your framework are you using?
"next": "15.0.3",
Description
I am unable to test with nuqs without mocking in NextJS and Jest. NextJS has its own code transformer and Jest config wrapper, so it is difficult to follow the Nuqs/Jest guide and use experimental ESM support. Instead, I've been relying on NextJS config transpilePackages option to port the node packages back to CommonJS.
However, with the esm-only.cjs
file, I'll get an exception in my tests. But even if I remove the manual exception, my test still cannot find the correct module. I suspect maybe #880 might fix this, but with the NextJS Jest wrapper over Jest config, it didn't work :(
Really want to not mock and wish jest supports ESM out of the box :( but meanwhile, are there any workarounds?
Reproduction
- Setup Jest in NextJS following NextJS testing guide
- Try to use Nuqs in a Jest test
- Fails :(