Skip to content

Mock fetch inside API route #1125

Answered by Xunnamius
adrianrios25 asked this question in Q&A
Discussion options

You must be logged in to vote

That's a strange error, and it doesn't seem like it has to do with NTARH directly if things are working in your local environment. Without a minimal example repo demonstrating this error, I can only make some guesses:

  • Your test is trying to import something AFTER Jest has ended. This is a sign that you are not awaiting a promise somewhere where you should be. If this unawaited promise is in your test file or in your source files somewhere, I am not sure. I use eslint's promise rules to catch these types of errors since they can get pretty tough to debug manually, especially in a CI pipeline. There's also --detectOpenHandles.

  • Your simple fetch mock is hiding some sort of complexity whe…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@adrianrios25
Comment options

Answer selected by adrianrios25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn't working
2 participants
Converted from issue

This discussion was converted from issue #1124 on November 17, 2024 09:41.