Test file-uploading API Endpoint #837
-
I just discovered this library, and it seems to be exactly what I need, except ... I need to test a file-upload API, and I couldn't find any examples in the documentation of testing such endpoints. Is it possible, and if so are there any examples or docs I can reference? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi there. Each invocation of If you want to test that your endpoint handles file uploads as expected, it should be no different than uploading a file using |
Beta Was this translation helpful? Give feedback.
Hi there. Each invocation of
testApiHandler
spins up a tiny transient HTTP server on a random port, to which thefetch
function sends your requests. That server calls out to the Next.js internal functionapiResolver
, which handles the request entirely.If you want to test that your endpoint handles file uploads as expected, it should be no different than uploading a file using
fetch
normally.