We have Next.js application that uses the
next/jest configurator to set up jest in a good way for Next projects. Recently we added the @piwikpro/next-piwik-pro package to our app, as recommended by the Piwik docs. Tracking is working fine, but the integration tests are failing. The error message from Jest is
It seems that the import statement from the next-piwik-pro package is not appreciated by jest, and that this occurs because node_modules are never transpiled when using next/jest.
I’m certainly not an expert in these matters, but would it be possible to include a commonjs build with the npm package? Or maybe there is another way to work around this?
I have tried several different approaches, including manipulating the the config generated from nextJest (failed because the return type not a basic object but something complicated with a bunch of async things) and running jest in ESM mode. Could not make any progress with that.