Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch-mock not working after update to Node v18 #658

Open
mfernandes-alcumus opened this issue Aug 22, 2023 · 3 comments
Open

fetch-mock not working after update to Node v18 #658

mfernandes-alcumus opened this issue Aug 22, 2023 · 3 comments

Comments

@mfernandes-alcumus
Copy link

Fetch is not getting mocked after updating to node v18

tomlarkworthy pushed a commit to tomlarkworthy/cloudworker-proxy that referenced this issue Sep 1, 2023
added test for s3 which does not work due to wheresrhys/fetch-mock#658
@metart43
Copy link

@mfernandes-alcumus Hey, I faced the same issue when migrating from Node v16 to Node v18.

Use the --no-experimental-fetch flag when running tests to disable the global fetch, ensuring that fetch-mock works as expected.

You can read about why you are facing this issue here.

https://nodejs.org/en/blog/announcements/v18-release-announce#fetch-experimental

The global fetch in Node.js 18 is labeled as "experimental." This means it might not be fully stable or might have behaviors that differ from other fetch implementations. By using the --no-experimental-fetch flag, you're essentially reverting to the previous behavior, where there's no global fetch, making libraries like fetch-mock behave as expected.

@mfernandes-alcumus
Copy link
Author

thanks @metart43 that is very helpful

@peterholak
Copy link

peterholak commented Jan 24, 2024

fetch is stable in Node.js 21 https://nodejs.org/en/blog/announcements/v21-release-announce#stable-fetchwebstreams, not experimental anymore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants