Skip to content

Test file-uploading API Endpoint #837

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

You must be logged in to vote

Hi there. Each invocation of testApiHandler spins up a tiny transient HTTP server on a random port, to which the fetch function sends your requests. That server calls out to the Next.js internal function apiResolver, 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.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by machineghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request
2 participants
Converted from issue

This discussion was converted from issue #836 on June 13, 2023 23:05.