Closed ricokahler closed 3 years ago
FYI here is how I fixed this in Next Right Now, I had a similar issue in Jest tests:
/**
* Importing next during test applies automated polyfills:
* - Polyfill the built-in "fetch" provided by Next.js
*
* @see https://github.com/vercel/next.js/discussions/13678#discussioncomment-22383 How to use built-in fetch in tests?
* @see https://nextjs.org/blog/next-9-4#improved-built-in-fetch-support Next.js Blog - Improved Built-in Fetch Support
* @see https://jestjs.io/docs/en/configuration#setupfilesafterenv-array About setupFilesAfterEnv usage
*/
require('next');
oh very cool. seem like a quick one. i'll give this a try and release soon after if it works out
Awesome, I wasn't sure it would be that easy! Glad it is ;)
One inconsistency I've noticed is that Next.js will provide a global fetch function in Node environments. Right now
next-plugin-preval
does not do that and it should!