Mock fetch inside API route #1125
-
The problemI'm calling fetch api inside my api route so in my test I have tried something like this
this is working when I run the test in local but in azure pipeline I'm getting this error. Is there a way to do this properly?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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:
|
Beta Was this translation helpful? Give feedback.
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…