When running Jest tests in my Next.js (v15) project, the test suite fails with an error indicating that the nuqs package is ESM only. This prevents me from successfully executing tests that involve components or hooks utilizing nuqs.
Jest version "jest": "^29.7.0"
● Test suite failed to run
This package is ESM only.
See https://github.com/47ng/nuqs/issues/691 for more details.
13 | type QuoteAction = typeof createQuote | typeof updateQuote;
14 |
> 15 | const useCreateQuote = () => {
| ^
16 | const queryClient = useQueryClient();
17 | const [quoteId, setQuoteId] = useQueryState('quote');
18 | const action: QuoteAction = quoteId ? updateQuote : createQuote;
at Object.<anonymous> (node_modules/nuqs/esm-only.cjs:6:7)
at Object.<anonymous> (hooks/use-create-quote.ts:15:15)
at Object.<anonymous> (hooks/index.ts:37:64)
at Object.<anonymous> (components/forms/policy-details-form.tsx:24:16)
at Object.<anonymous> (__tests__/components/form/policy-details-form.spec.tsx:7:67)
Reproduction
Initialize a Next.js (v15) project and install nuqs.
Configure Jest for testing within the project.
Create a component or hook that utilizes nuqs (e.g., useCreateQuote).
Write and run Jest tests for the component or hook.
Observe the failure with the message "This package is ESM only."
What's your version of
nuqs
?"nuqs": "^2.1.1"
What framework are you using?
Which version of your framework are you using?
"next": "^15.0.2"
Description
When running Jest tests in my Next.js (v15) project, the test suite fails with an error indicating that the nuqs package is ESM only. This prevents me from successfully executing tests that involve components or hooks utilizing nuqs. Jest version "jest": "^29.7.0"
● Test suite failed to run
Reproduction