Is there a good way to mock the fetch function? #18809
Answered
by
ParitoshBh
justinmchase
asked this question in
Q&A
-
Do you just stub it or is there a simpler way like I also found this which looks really promising, if a little old: Is there a std library solution for this? |
Beta Was this translation helpful? Give feedback.
Answered by
ParitoshBh
Dec 23, 2024
Replies: 1 comment
-
Wouldn't something like, import { stub } from "@std/testing/mock";
const fetchStub = stub(globalThis, 'fetch', (url, ...rest) => {
return Promise.resolve(new Response());
}); suffice? |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
justinmchase
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wouldn't something like,
suffice?